I have a problem upon exiting my application (in debug mode). It's related to the SkinManager which seems to get accessed after the SkinManager instance has been deleted.
On exiting the application, this error is launched:
Unhandled exception at 0x0987EAA6 (ToolkitPro1630vc110D.dll) in XXX.exe: 0xC0000005: Access violation reading location 0xFEEEFF36. |
Hitting break leads to the function GetMetrics() of CXTPSkinManagerSchema. One step higher, I'm in CXTPSkinManager::GetMetrics() and even one step higher I'm in CXTPSkinManagerApiHook::OnHookDeleteObject().
Now, this function is called upon exiting the application (callstack via CCmdTarget::OnFinalRelease()). It shows that XTPSkinManager() returns a "valid" pointer, which in fact is a singleton instance.
Further debugging and placing a breakpoint in the destructor of the CXTPSkinManager, it shows that it's actually destructed BEFORE the CXTPSkinManagerApiHook::OnHookDeleteObject() has been called.
The destructor looks like this:
static class CXTPSkinManager::CDestructor{ public: ~CDestructor() { if (s_pInstance != NULL) delete s_pInstance; }
} __xtpSkinManagerDestructor; |
It's clear that either the destruction should be called much later OR that the s_pInstance should be set to NULL.
I've tried latter solution but this leads to memory leaks, since a new SkinManager instance is created via XTPSkinManager()->GetMetrics() in CXTPSkinManagerApiHook::OnHookDeleteObject() which is then not deleted anymore.
Did you solve this bug?
|