The COM Game
Jul. 9th, 2015 11:05 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
We still use OLE compound document files to store our entities on a desktop. This normally works pretty well until someone does something odd in our code. In this case, what someone did was some fancy footwork with opening and closing the storage underneath a document in order to get it to be smaller than it would otherwise be by saving it as a new storage.
The only problem is that it doesn't work. It looks like something else has grabbed a reference to the underlying IStorage and the associated IPropertySetStorage.
Figuring out what did this is just a wee bit challenging since there's no way to directly observe the reference counts in the debugger. The only way to get a reference count on a COM object is to AddRef and Release it, each of which will return the current reference count. And that trick doesn't work if you used a smart COM pointer, because you aren't allowed to AddRef and Release those directly, so you have to create a new reference to the IStorage and AddRef/Release it to get the overall reference count.
At the moment, I am extremely annoyed and getting ready to add a lot of instrumentation to this mess so I can sort it out.
*grumble*
In other news, Katie asked me to send you a message: :)
The only problem is that it doesn't work. It looks like something else has grabbed a reference to the underlying IStorage and the associated IPropertySetStorage.
Figuring out what did this is just a wee bit challenging since there's no way to directly observe the reference counts in the debugger. The only way to get a reference count on a COM object is to AddRef and Release it, each of which will return the current reference count. And that trick doesn't work if you used a smart COM pointer, because you aren't allowed to AddRef and Release those directly, so you have to create a new reference to the IStorage and AddRef/Release it to get the overall reference count.
At the moment, I am extremely annoyed and getting ready to add a lot of instrumentation to this mess so I can sort it out.
*grumble*
In other news, Katie asked me to send you a message: :)