Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Crash inside CXTPFontDC::SetFont()
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Crash inside CXTPFontDC::SetFont()

 Post Reply Post Reply
Author
Message
akur View Drop Down
Senior Member
Senior Member


Joined: 16 May 2006
Status: Offline
Points: 139
Post Options Post Options   Thanks (0) Thanks(0)   Quote akur Quote  Post ReplyReply Direct Link To This Post Topic: Crash inside CXTPFontDC::SetFont()
    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!


Back to Top
akur View Drop Down
Senior Member
Senior Member


Joined: 16 May 2006
Status: Offline
Points: 139
Post Options Post Options   Thanks (0) Thanks(0)   Quote akur Quote  Post ReplyReply Direct Link To This Post 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?

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
akur View Drop Down
Senior Member
Senior Member


Joined: 16 May 2006
Status: Offline
Points: 139
Post Options Post Options   Thanks (0) Thanks(0)   Quote akur Quote  Post ReplyReply Direct Link To This Post 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!

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
akur View Drop Down
Senior Member
Senior Member


Joined: 16 May 2006
Status: Offline
Points: 139
Post Options Post Options   Thanks (0) Thanks(0)   Quote akur Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.188 seconds.