On Tue, 21 Sep 2004, Steve Hay wrote:
> I'm a little wary of this fix because MSDN docs say "An apartment must
> call CoUninitialize once for each successful call it has made to
> CoInitialize" and "CoUninitialize should be called on application
> shutdown", but it certainly seems to work and is less messy than what
> I was doing.

I believe the reason you should call CoUninitialize() explicitly is to
get proper cleanup of "hanging" COM objects whose reference counts
haven't been properly maintained.  Once the thread or process shuts down,
it is no longer possible to properly finalize those objects.  If
all your COM objects have been properly disposed, then you should be fine.
Win32::Shortcut doesn't maintain reference counts itself, so I wouldn't worry
about this too much.

There is also a race condition when 2 modules try to call CoUninitialize(),
e.g. Win32::Shortcut and Win32::OLE.  If Win32::Shortcut has been loaded last,
then its END block will be executed first, and the DESTROY methods of all
still existing Win32::OLE methods will fail.

Cheers,
-Jan



-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

Reply via email to