GdiPlus Registering Race Condition |
Post Reply |
Author | |
mgampi
Senior Member Joined: 14 July 2003 Status: Offline Points: 1201 |
Post Options
Thanks(0)
Posted: 03 September 2018 at 6:07am |
Hello,
when creating two different CXTPMarkupContexts both call in their constructor the function CXTPMarkupDrawingContext::Register(TRUE). As this leads to a registering of the CXTPSingleton CXTPGdiPlus 2x sometimes an assertion will be caused, when we got a bad timing. Can anyone please help me solve this issue by fixing the race condition or telling me if I've used these classes in a wrong way and how to use them correctly? Thanks for the help in advance. |
|
Martin Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0 Platform: Windows 10 v 22H2 (64bit) Language: VC++ 2022 |
|
agontarenko
Admin Group Joined: 25 March 2016 Status: Offline Points: 299 |
Post Options
Thanks(0)
|
Hello Martin, how I can reproduce it with our samples? Regards, Artem Gontarenko
|
|
mgampi
Senior Member Joined: 14 July 2003 Status: Offline Points: 1201 |
Post Options
Thanks(0)
|
Hello,
the easiest way would be to implement a sample that uses multithreading and do something like the following all the time until you get into the race condition:
CSampleMarkupView* Wnd_ = new CSampleMarkupView(); //Calls CXTPMarkupDrawingContext::Register(TRUE) -> calls CXTPGdiPlus::Register(TRUE) // with ASSERT(m_nGdiplusToken == 0 && m_hModule == 0) (XTPGdiPlus.cpp Line 61) delete Wnd_; //Calls CXTPMarkupDrawingContext::Register(FALSE) -> calls CXTPGdiPlus::Register(FALSE) /* XTPGdiPlus.cpp Line 75ff: m_nCount--; if (m_nCount != 0) return; -----------------> if another thread that wants to call CXTPMarkupDrawingContext::Register(TRUE) interrupts our thread we got an assertion (ASSERT(m_nGdiplusToken == 0 && m_hModule == 0)) in XTPGdiPlus.cpp Line 61 if (m_hModule) { // Termination of background thread, which is causing the shutdown problem. gdiplusStartupOutput.NotificationUnhook(m_nGdiplusToken); GdiplusShutdown(m_nGdiplusToken); FreeLibrary(m_hModule); } m_hModule = NULL; m_nGdiplusToken = 0; */ using: class CSampleMarkupView : public CWnd, CXTPMarkupContext { public: CSampleMarkupView() : CWnd(), CXTPMarkupContext() {} virtual ~CSampleMarkupView() {} }; Best regards |
|
Martin Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0 Platform: Windows 10 v 22H2 (64bit) Language: VC++ 2022 |
|
mgampi
Senior Member Joined: 14 July 2003 Status: Offline Points: 1201 |
Post Options
Thanks(0)
|
Fixed it.
Thanks for the help! :)
|
|
Martin Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0 Platform: Windows 10 v 22H2 (64bit) Language: VC++ 2022 |
|
Marco1
Senior Member Joined: 16 January 2004 Location: Germany Status: Offline Points: 251 |
Post Options
Thanks(0)
|
Was this problem related to your program?
|
|
mgampi
Senior Member Joined: 14 July 2003 Status: Offline Points: 1201 |
Post Options
Thanks(0)
|
Yes! It's been my fault...
|
|
Martin Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0 Platform: Windows 10 v 22H2 (64bit) Language: VC++ 2022 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |