10.4.2 print preview assert/crash |
Post Reply |
Author | |
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
Posted: 09 February 2007 at 3:18pm |
Hello, I noticed the following bug while running a version of my app using 10.4.2. When you close the application with a calendar view print preview active it will assert (crash in release) in the destructor at the noted line: CXTPCalendarControlView::~CXTPCalendarControlView() { if (m_bReleaseCalendarWhenDestroy) { CMDTARGET_RELEASE(m_pCalendar); } ASSERT(m_pUpdateContect == NULL); // <<<< will assert here SAFE_DELETE(m_pUpdateContect); CMDTARGET_RELEASE(m_pPrintOptions); } Apparently the contect (context?) isn't freed up ahead of time. This bug is also present in the calendardemo sample. |
|
sserge
Moderator Group Joined: 01 December 2004 Status: Offline Points: 1297 |
Post Options
Thanks(0)
|
Normally m_pUpdateContect (yes, should be context) is destroyed in CXTPCalendarControlView::OnEndPrinting.
This ASSERT means that PrintPreview was not correclty finished. And how can you exit app without closing PrintPreview first? What is your VC version 6.0, 7.0, 7.1, 8.0 ? I tried on Calendar Demo sample - both Alt+F4 and "x" button close PrintPreview on first click, on the second one app is closed. -- WBR, Serge |
|
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
|
Solved. It had nothing to do with the Codejock code.
Sserge's hint regarding "And how can you exit app without closing PrintPreview first?" tipped me off to trace there. I was assuming PrintPreview would close itself! This is not always the case. I was running both the sample and my app through an MDI framework. In the MDI framework the order of dispose is ordered from 1st to last view on the same doc. The Calendar view was being disposed before the Preview view and the Preview view close could never be reached. In order to solve, set a BOOL flag in the doc that the Preview view is associated with. In the "OnCloseDocument()" in the doc file, catch the flag and send a close preview message to all the views associated with the doc. void CCalendarDoc::OnCloseDocument() { if ( m_bIsPreview ) { m_bIsPreview = FALSE; POSITION pos = GetFirstViewPosition(); while (pos != NULL) { CView* pView = GetNextView(pos); pView->SendMessage( WM_COMMAND, AFX_ID_PREVIEW_CLOSE, 0); } return; } // rest of close document stuff here } In the view where you have the print preview, OnFilePrintPreview(), set the BOOL flag so the document knows the status if it goes to close: void CCalendarView::OnFilePrintPreview() { CCalendarDoc* pDoc = (CCalendarDoc*)GetDocument() ; pDoc->m_bIsPreview = TRUE ; // rest of the printpreview stuff goes here } Now you should be able to close the document by any normal means and it will pick up and send the signal to close printpreview. Thanks for the hint Sserge |
|
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 |