![]() |
Possible Bug in Print Preview |
Post Reply ![]() |
Author | |
JonN ![]() Newbie ![]() ![]() Joined: 11 January 2004 Location: United Kingdom Status: Offline Points: 8 |
![]() ![]() ![]() ![]() ![]() 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?
|
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hi, What vc version do you have?
What line of code in MFC sources have problem?
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
JonN ![]() Newbie ![]() ![]() Joined: 11 January 2004 Location: United Kingdom Status: Offline Points: 8 |
![]() ![]() ![]() ![]() ![]() |
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!
|
|
![]() |
|
JonN ![]() Newbie ![]() ![]() Joined: 11 January 2004 Location: United Kingdom Status: Offline Points: 8 |
![]() ![]() ![]() ![]() ![]() |
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.
![]() Jon Neades
|
|
![]() |
|
JonN ![]() Newbie ![]() ![]() Joined: 11 January 2004 Location: United Kingdom Status: Offline Points: 8 |
![]() ![]() ![]() ![]() ![]() |
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
|
|
![]() |
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 |