"RedLars" <Liverpool1892@gmail.com> ha scritto nel messaggio
COleDataSource * pDataSource = new COleDataSource;
// fill-in code
This code works! The correct data is transferred to the destination!
The problem now is cleaning up.
Adding a delete pDataSource causes an access violation in destination
What I've noticed is that pDataSource->m_dwRef is increment to 1 on
creation and increased to 3 if OnDragEnter\OnDragDrop or OnDragEnter
\OnDragLeave occurs in destination code.
Those OLE objects are reference counted, so I would not call 'delete' on
I would "respect" their contract of AddRef/Release (these are methods
present in IUknown, the root interface for COM/OLE objects).
Seen some code example use the following pattern:
if ( pDataSource->m_dwRef <= 1)
I would just call ->ExternalRelease (or InternalRelease, if there is no
I think that the difference between External and Internal is about
aggregation: External methods like ExternalRelease are to properly manage
// if there's no aggregation
I believe that Internal/ExternalRelease will decrement the reference count,
and call C++ 'delete' if reference count is 0.
However, I'm not sure about that, and I would prefer experimenting with some
real code, also considering that you are mixing MFC and managed world of
..NET here... (I think that computer science is an "experimental" science :)
we need compilers, debuggers, log files, etc. to diagnose things and try to
find solutions to bug.)
BTW: I would also post this question in the ATL group.
There is a COM very expert there whose name is Igor (T.): he knows a lot
about COM and OLE and I believe he will give you a detailed answer...