Print Page | Close Window

Crash inside CXTPFontDC::SetFont()

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=8031
Printed Date: 21 May 2024 at 5:09pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Crash inside CXTPFontDC::SetFont()
Posted By: akur
Subject: Crash inside CXTPFontDC::SetFont()
Date Posted: 17 September 2007 at 2:43am
Hello,

we've got access violation crashes inside the CXTPFontDC class. This is how the call stack looks like (excerpt from a Release build's crashdump):



It happens sporadically from time to time (like once a week), but on 3 different computers at least. All these computers run Vista Business or Vista Ultimate and all of them are dual-core processors. Don't know if it matters.

Do you have any idea how to fix or any workaround for this?
Thanks a lot, in advance!





Replies:
Posted By: akur
Date Posted: 17 September 2007 at 2:45am
The call stack comes from processing WM_PRINT or WM_PRINTCLIENT messages which is what e.g. plain combobox controls are sent to on Vista systems when you e.g. hover your mouse over them. However, the crash doesn't happen during hovering. It just happens when working with any other parts of the application.

We have one such plain combobox inserted as a custom control in an XTP toolbar. Do you think this can cause any problems somehow?



Posted By: Oleg
Date Posted: 17 September 2007 at 5:26am
Hi,
 
Looking to code and call stack I can say that it can happen only if something send not valid device context with WM_PRINT message.
 
try to remove this comboxbox and check if problem can be reproduced. May be you can replace it to our CXTPControlComboBox ?


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: akur
Date Posted: 17 September 2007 at 5:57am
Hello,
the WM_PRINT is sent by the system (Vista) itself, so I guess the device context should be valid. Plus, its validity is checked in your code inside CXTPCommandBar::DrawCommandBar(), so I think this is not the problem.

However, maybe the CDC object itself - acquired inside CXTPCommandBar::OnPrint() - can be deleted somehow, thus a non-valid object is dereferenced inside the ctor of CXTPFontDC. What do you think, how can this happen? I've got no good explanation for this, since MFC should delete temporary CDC objects only during OnIdle() - but that's _not_ our case, since we're still inside the processing of the same WM_PRINT message.

I'm affraid we cannot replace our specialized, owner-draw combobox with a CXTPControl-based class. Do you have any other idea how to get around this crash?
Thank you, in advance!



Posted By: Oleg
Date Posted: 18 September 2007 at 2:20am
Hello,
 
Please try to rewrite CXTPCommandBar::OnPrintClient as
 
 CDC dc;
 dc.Attach((HDC)wParam);
 DrawCommandBar(&dc, CXTPClientRect(this));
 dc.Detach();
 
and check if you can reproduce it.
 
Thanks


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: akur
Date Posted: 22 October 2007 at 6:52am
Thanks for the suggestion - it helped to avoid the crash so far.
I guess there must be some problem with how MFC maintains its map of temporary CDC objects.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net