[PATCH 1/3] uiautomationcore: Implement UiaGetReservedNotSupportedValue.

Connor McAdams cmcadams at codeweavers.com
Wed Oct 27 15:24:21 CDT 2021


On Wed, Oct 27, 2021 at 11:12:31PM +0300, Nikolay Sivov wrote:
> 
> 
> On 10/27/21 10:55 PM, Connor McAdams wrote:
> > +/*
> > + * When passing the ReservedNotSupportedValue/ReservedMixedAttributeValue
> > + * interface pointers across apartments within the same process, use the
> > + * free threaded marshaler to preserve the pointer value. Wrap the IMarshal
> > + * interface received by CoCreateFreeThreadedMarshaler so that we can maintain
> > + * our own reference count and release the object when it hits 0.
> > + */
> > +static HRESULT uia_reserved_val_create_ftm(IUnknown *outer, IMarshal **marshaler)
> I don't understand this part, if every QI for IMarshal returns new
> instance, why do need a wrapper? And which object do you mean to
> release, with our own reference count?
>

CoCreateFreeThreadedMarshaler with a non-NULL outer argument returns an
IMarshal interface that has its reference count tied to the reference
count of the outer object. In this case, AddRef/Release on the reserved
object is pointless, because it is a static object whose reference count
doesn't (and probably shouldn't) change.

Normally, when the outer objects reference count hits 0, you'd release
the unique inner IUnknown interface created by CoCreateFreeThreadedMarshaler
there. We can't do that here, so my only idea was to create a unique
IMarshal 'wrapper' interface with its own reference count, so that when
it hits 0, we release the inner IUnknown object and free the memory.



More information about the wine-devel mailing list