Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Possible Bug in Print Preview
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Possible Bug in Print Preview

 Post Reply Post Reply
Author
Message
JonN View Drop Down
Newbie
Newbie
Avatar

Joined: 11 January 2004
Location: United Kingdom
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote JonN Quote  Post ReplyReply Direct Link To This Post Topic: Possible Bug in Print Preview
    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?
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: 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
Back to Top
JonN View Drop Down
Newbie
Newbie
Avatar

Joined: 11 January 2004
Location: United Kingdom
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote JonN Quote  Post ReplyReply Direct Link To This Post 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!
Back to Top
JonN View Drop Down
Newbie
Newbie
Avatar

Joined: 11 January 2004
Location: United Kingdom
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote JonN Quote  Post ReplyReply Direct Link To This Post 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:
 
 
Jon Neades
 
Back to Top
JonN View Drop Down
Newbie
Newbie
Avatar

Joined: 11 January 2004
Location: United Kingdom
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote JonN Quote  Post ReplyReply Direct Link To This Post 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
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.047 seconds.