Search it in windows
Releasing WinRT Runtime Classes
As I understand it, all references to Windows Runtime Classes are Interfaces. When handling projected types of the Interfaces/Objects we are inherently holding a smart pointer. But how do we release a reference to the underlying object? It makes no sense to cast to the implementation, or to get IUknown somehow and calling release(). There's no function on the projected type to release. The winrt::final_release function seems to have been deprecated. There doesn't seem to be any other winrt function. ~IUknown does not sound like it would decrement the count. My only conclusion is to IInterface = nullptr. Great if that's the answer, and it might even work, but still be not the right answer.
2 answers
Sort by: Most helpful
-
-
Rebeka Fox 106 Reputation points
2022-08-26T09:44:19.507+00:00 I was unaware that because I was implementing through a Proxy-Stub Server, that I was hiding the ->AddRef() and ->Release() functions. I assumed projection types hid this by default, which was an incorrect assumption. I had never implemented the expected way, or without 'late binding'. That said, projection type Midl 3.0 Interfaces are very much so smart pointers and when any reference goes out of scope the underlying object is decremented or assigning to another reference increments it. A simple test through the Proxy-Stub Server showed that setting any reference to nullptr decrements the internal objects count. ->Release() is not required. I love C++/WinRT and WinUI 3.0, these are amazing technologies.