[FONTVIEW]

* Restructure Display_OnPrint to eliminate allocating an unused variable and plug a leak.

svn path=/trunk/; revision=59230
This commit is contained in:
Amine Khaldi 2013-06-16 12:43:35 +00:00
parent 78a3d923b6
commit a2949de657

View file

@ -417,13 +417,6 @@ Display_OnPrint(HWND hwnd)
PRINTDLG pfont; PRINTDLG pfont;
TEXTMETRIC tm; TEXTMETRIC tm;
int copies, yPos; int copies, yPos;
DISPLAYDATA* pData;
pData = malloc(sizeof(DISPLAYDATA));
ZeroMemory(pData, sizeof(DISPLAYDATA));
/* Sets up the font layout */
pData = (DISPLAYDATA*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
/* Clears the memory before using it */ /* Clears the memory before using it */
ZeroMemory(&pfont, sizeof(pfont)); ZeroMemory(&pfont, sizeof(pfont));
@ -443,7 +436,15 @@ Display_OnPrint(HWND hwnd)
if (PrintDlg(&pfont)) if (PrintDlg(&pfont))
{ {
DOCINFO docinfo; DOCINFO docinfo;
#if 0
DISPLAYDATA* pData;
pData = malloc(sizeof(DISPLAYDATA));
ZeroMemory(pData, sizeof(DISPLAYDATA));
/* Sets up the font layout */
pData = (DISPLAYDATA*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
#endif
docinfo.cbSize = sizeof(DOCINFO); docinfo.cbSize = sizeof(DOCINFO);
docinfo.lpszDocName = "Printing Font"; docinfo.lpszDocName = "Printing Font";
docinfo.lpszOutput = NULL; docinfo.lpszOutput = NULL;
@ -470,7 +471,9 @@ Display_OnPrint(HWND hwnd)
/* TODO: Determine if using Display_DrawText() will work for both rendering out to the /* TODO: Determine if using Display_DrawText() will work for both rendering out to the
window and to the printer output */ window and to the printer output */
//Display_DrawText(pfont.hDC, pData, yPos); #if 0
Display_DrawText(pfont.hDC, pData, yPos);
#endif
/* Ends the current page */ /* Ends the current page */
EndPage(pfont.hDC); EndPage(pfont.hDC);
@ -487,13 +490,12 @@ Display_OnPrint(HWND hwnd)
EndDoc(pfont.hDC); EndDoc(pfont.hDC);
DeleteDC(pfont.hDC); DeleteDC(pfont.hDC);
} else { #if 0
return 0; /* Frees the memory since we no longer need it for now */
free(pData);
#endif
} }
/* Frees the memory since we no longer need it for now */
free(pData);
return 0; return 0;
} }