http://bugs.winehq.org/show_bug.cgi?id=4436
------- Additional Comments From mike@codeweavers.com 2006-12-02 21:11 -------
I could introduce a private interface, but this would only work if an IStream could be guaranteed only ever to be created as a child of an IStorage - this would break encapsulation.
There are many implementations of IStream (some that are not related to an IStorage), however the OLE storage implementation that you're dealing with will always be created from IStorage_OpenStream or IStorage_CreateStream.
IStream is an interface, not a class of object. OLE Object classes can have many interfaces, and two objects classes can have different implementations of the same interface.
I think you want (sorry for the poor ascii art):
.------------------. | | | OLE storage obj |O--- IUnknown | | | list of |O--- IStorage | stream objs | | | '------------------' | private .--------------------. | | |O--- IUnknown '------| OLE stream object | | has pStorageImpl |O--- IStream '--------------------'
O--- denotes a COM interface to an object
When IStorage is destroyed, iterate its list of stream objects, and set their pStorageImpl to NULL (we know their flavour, since they're objects that we created with IStorage_OpenStream).
You might need some more tests to see the behaviour of a stream object when it's parent storage has been released.