O/H Boris Zbarsky έγραψε:
On 11/2/09 8:31 PM, Boris Zbarsky wrote:
http://tkgecko.svn.sourceforge.net/viewvc/tkgecko/tkgecko/src/
It might help to carefully trace through the functions you're
executing. I can't tell from here which they are, but for example
Browser::GetEncoder leaks |doc|. Browser::SaveDocument leaks |document|.
Can you please suggest what is the correct way to call GetEncoder?
What I currently do, is the following:
I am at the Tcl script level. I call DOM::GetEncoder, which uses
QueueEvent to queue the request "get_encoder" in the gtk/mozilla thread,
which in turn will call Browser::GetEncoder.
Browser::GetEncoder will create & reference an encoder object, and also
create & reference a proxy object.
The proxy object is returned to Tcl, where I call AddRef & Release on
the proxy object.
Am I still leaking |doc|?
The Tcl code that uses it is like this:
set encoder [$dom GetEncoder text/plain 0]
$encoder AddRef
$encoder SetNode $body
set content [$encoder EncodeToString]
$encoder SetNode NULL
$encoder Release
Have I forgot to release anything?
I assume that I have to release only the proxy object (which takes care
also the original object). When I release the encoder from the Tcl
script, it remains referenced only by the Browser object, until the next
GetEncoder. Is it so?
I can't find your QueueEvent implementation, but this code in DOM::DOM:
39 mBrowser->QueueEvent(&p, "get_document");
40 document = p.document;
looks possibly suspect to me, depending on how your get_document is
impemented.
"get_document" simply calls Browser::GetProxyForDocument.
(http://tkgecko.svn.sourceforge.net/viewvc/tkgecko/tkgecko/src/TkGecko_Browser.cpp?revision=19&view=markup)
The idea is that the Browser class does not play with the reference
counts, and these are done manually (with AddRef/Release) from the Tcl
script level.
Thank you,
George
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding