TypeLib containment refcounting

Kelly Leahy kellyleahy at swbell.net
Mon Jun 16 14:43:25 CDT 2003

I would expect you to addref the typelib when the ITypeInfo pointer is
created, and then when it is destroyed to release it.

In the object that implements the ITypeInfo reference, you should have a
pTypeLib->Release() in the destructor and a pTypeLib->AddRef() somewhere in
the code that creates the ITypeInfo implementing object.  If, for instance,
the ITypeLib pointer is passed to the constructor of this object, then the
constructor should look something like...

m_pTypeLib = pTypeLib;

and the destructor should look like



----- Original Message ----- 
From: "Mike Hearn" <mike at theoretic.com>
To: <wine-devel at winehq.com>
Sent: Monday, June 16, 2003 2:28 PM
Subject: Re: TypeLib containment refcounting

> > This doesn't look right, you increment the refcount on every GetTypeInfo
> > but only decrement when the typeinfo object is destroyed.
> Well, unless you can call GetTypeInfoOfGuid twice and get two pointers to
> the same interface (maybe you can, i don't really know but that would seem
> unusual), I don't understand why this is wrong. When somebody calls
> GetTypeInfoOfGuid they get an interface, so at some point they should
> release it, which will in turn release the reference to the typelib.
> Without this patch, an app did a GetTypeInfo, released the typelib object
> and then tried to get the container from ITypeInfo which obviously crashed
> when it tried to do an AddRef on the destroyed object.
> Otherwise I don't really understand how this should work, unless you
> manually add a reference for every type info object when the typelib is
> first constructed, then manually release also for every object. That would
> seem a bit odd though, to me.
> Could you or somebody else explain how this should work?
> thanks -mike

More information about the wine-devel mailing list