Re: Visual Studio 2005 - Firing Events from a Worker Thread
"Chris" <chris@scadaengine.com> wrote in message
news:1167683346.555616.16620@42g2000cwt.googlegroups.com
Sorry, I should have provided more information.
The article is on CodeGuru at
http://www.codeguru.com/cpp/com-tech/atl/atl/article.php/c75/
All I did was download the sample, convert and compile it under Visual
Studio 2005 and it crashes. This code compiles and works under Visual
Studio 6.
Implementation of CComDynamicUnkArray has changed.
CComDynamicUnkArray_GIT relies on implementation details.
It used to be in VC6 that CComDynamicUnkArray::Add(IUnknown*) returned
IUnknown* pointer itself, cast to a DWORD. In VC7 and up this has
changed - what's returned is an index into the array of pointers. The
change is probably due to the fact that casting pointers to DWORDs is
not such a smart move on 64bit.
CComDynamicUnkArray_GIT however assumes VC6 implementation. In
particular, CComDynamicUnkArray_GIT::GetAt calls
CComDynamicUnkArray::GetAt, casts the returned IUnknown* pointer to a
DWORD and assumes it's the same DWORD that was earlier returned by
CComDynamicUnkArray::Add, which it's not. Not finding the cookie in its
internal map, it casts the DWORD back to IUnknown* and returns that.
This is the original, unmarshalled IUnknown, so we are back to precisely
the same problem we started with.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925