Hey all, I realize this may not be the most appropriate newsgroup to
post this msg, but I've been struggling with this one for several days
to bo avail.. so my apologies. Still, I'm hopeful someone out there
more knowledgeable than I can help shine some light on the problem
here.

I've written a scriptable mozilla plugin based on the npsimple sample
available in the sdk. My plugin code uses a smart pointer to
instantiate a com object, calls a function, returns the result and then
releases the object. I even go so far as to exec CoUninitialize() in
the same routine to be certain that all references are released.
However, the object is not actually released until after the current
browser instance is terminated.

Here is a sample of the code inside the function that
instantiates/calls/releases the activex control (made some adjustments
for the sake of readability):

---------------------------------------
void nsPluginInstance::readyToUpdate(int *bResult)
{
_GeneralHandlerPtr ptrGH;
BOOL bR = false;

HRESULT hrCI = CoInitialize(NULL);
if (SUCCEEDED(hrCI)) {
HRESULT hrGH = ptrGH.CreateInstance(__uuidof(GeneralHandler));

if (SUCCEEDED(hrGH)) {
bR = ptrGH->readyToUpdate();
ptrGH.Release();
}

CoUninitialize();
}

*bResult = bR;
}
---------------------------------------

If I take the very same code and toss it into a standard win32
executable, the object is released as soon as I call CoUninitialize(),
or ptrGH.Release() for that matter.

FYI - I know the com object is still hanging around because it creates
mutex and if I check for the existence of this mutex after calling the
above function it still exists. Also, if I try, say, to delete the .dll
containing the com object it also fails. However, as soon as I close
the browser the mutex dissapears and the file can be deleted.

I have tried just about everything I can think of within the realm of
win32 com programming. This must be particular to the XPCOM and the
Mozilla plugin architecture? Something is clearly holding onto the
reference even though I attempt to release it. Do I have to call some
special release function? I am just missing something very obvious?

I need to be able to accomplish this because my plugin tells my
javascript that some files need to be updated, which then redirects the
user to a page that updates those files. If the object in question is
not released by the browser, the dll that needs to be updated is locked
and cannot be overwritten.
Your insight and assistance would be most appreciated.

Thanks,
Damian

_______________________________________________
Mozilla-xpcom mailing list
[email protected]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to