Print Page | Close Window

Possible Bug in Print Preview

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=6269
Printed Date: 13 June 2025 at 4:55pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Possible Bug in Print Preview
Posted By: JonN
Subject: Possible Bug in Print Preview
Date Posted: 30 January 2007 at 12:37pm
Using 10.4.2 I've discovered that my application and the sample Print Preview program crash when trying to display a CEditView in print preview.  (I didn't notice whether 10.4.0 crashes.)
 
MFC asserts in debug mode in the MFC module dcprev.cpp at CPreviewDC::ComputeDeltas(...) .
 
Other types of view display properly in print preview.
 
I've also disovered that the standard MFC implementation CPreviewView also crashes the same way, so it is possible this is a bug with Microsoft.
 
Does anyone know whether this is a known bug, or any workaround?



Replies:
Posted By: Oleg
Date Posted: 31 January 2007 at 1:19am

Hi,

What vc version do you have?
What line of code in MFC sources have problem?


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


Posted By: JonN
Date Posted: 31 January 2007 at 4:05am
Hi Oleg
 
I'm running VC 2005 with SP1 installed.
 
The crash occurs in line 604 of dcprev.cpp, in the line
 
*pnCurDelta = tmAttrib.tmAveCharWidth;
 
It appears that the pointer pnCurDelta is NULL, which cannot be correct!


Posted By: JonN
Date Posted: 31 January 2007 at 6:26am
A bit more research and it looks like this is a Microsoft bug introduced into VC2005 by SP1.  The Superpad MFC example also fails with the same error.  As yet no fix has been posted. .  For more info see:
 
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=254738 - https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=254738
 
Jon Neades
http://www.mathtech.co.uk - www.mathtech.co.uk
 


Posted By: JonN
Date Posted: 31 January 2007 at 9:16am

This problem lies in a change to the code in the calling function CPreviewDC::TabbedTextOut(..)  Starting at line 722 in dcprev.cpp we now have in SP1

int* pDeltas = NULL;
LPTSTR pOutputString = NULL;
int nRightFixup;
::ATL::CAutoVectorPtr<int> spDeltas;
::ATL::CAutoVectorPtr<TCHAR> spOutputString;
if(!spDeltas.Allocate(nCount) ||
  !spOutputString.Allocate(nCount))
{
return 0;
}
UINT uCount = nCount;
CSize sizeFinalExtent = ComputeDeltas(x, lpszString, uCount, TRUE, nTabPositions, lpnTabStopPositions, nTabOrigin,   pOutputString, pDeltas, nRightFixup);
 
Note that the ComputeDeltas call supplies the uninitialized pOutputString, pDeltas as parameters rather than the new spOutputString, spDeltas which are correctly defined and initialized using the ATL::CAutoVectorPt calls.

Earlier versions used the standard new and delete to allocate and delete the pOutputString, pDeltas variables. 
 
Still not sure of the easiest workaround though.  Rebuilding the MFC libraries is not very appealing!
 
Jon Neades
http://www.mathtech.co.uk - www.mathtech.co.uk



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