Hi Michael, > actually, no. > somebody _else_ could also listen for the OnCreate or whatever event and > retain a hard reference. you cannot know whether this happens. > if it happens, that hard reference will keep the disposed instance alive.
The cppuhelper implementations for the various Weak/Agg/Component/Impl/Helper base classes reset their weak adapter when they're about to be disposed. At least they do so when they're implicitly disposed by their refcount dropping to zero, but I'd expect they also do so when explicitly disposed, as long as the base class methods are called. >From then on, even if the C++ instance is technically still alive, querying the adapted object at the adapter will return NULL. However, for a few combinations of those Weak/Component helper classes this was prone to race conditions, which has been fixed for 3.2 only. > so, the fact that a WeakReference can be converted to a hard reference is > no guarantee that the instance has not been disposed. Well, it can't at least because even if the object is not disposed when you retrieve the hard ref, it can be disposed from a concurrent thread after that point, and before you can use it. So, /me thinks that in multi-threaded scenarios, *nothing* is a guarantee that an object you know is not disposed when you attempt to use it. Ciao Frank -- - Frank Schönheit, Software Engineer [email protected] - - Sun Microsystems http://www.sun.com/staroffice - - OpenOffice.org Base http://dba.openoffice.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
