PrintDlg should not store struct pointer in DWL_USER slot

Mike Hearn m.hearn at signal.qinetiq.com
Thu Jun 26 10:23:24 CDT 2003


Well that bug took an embarrassingly long time to find, especially
considering it was already fixed in the ANSI version of the function.

Basically storing struct pointers in the extra window bytes is wrong,
because for instance in this case Internet Explorer hooks part of the
dialog creation and stores its own structure there, causing the next
access to cause strange jumps, freezes and so on. A better solution is
to use SetProp.

ChangeLog:
Store PrintStructures in a window property instead of extra window bytes

-- 
Mike Hearn <m.hearn at signal.qinetiq.com>
QinetiQ - Malvern Technology Center
-------------- next part --------------
--- ../wine-03June2003/dlls/commdlg/printdlg.c	2003-05-29 15:56:13.000000000 +0100
+++ dlls/commdlg/printdlg.c	2003-06-26 16:18:36.000000000 +0100
@@ -2053,24 +2053,20 @@
     INT_PTR res = FALSE;
 
     if (uMsg!=WM_INITDIALOG) {
-       PrintStructures = (PRINT_PTRW*) GetWindowLongW(hDlg, DWL_USER);
+	PrintStructures = (PRINT_PTRW*) GetPropW(hDlg, "__WINE_PRINTDLGDATA");
 	if (!PrintStructures)
 	    return FALSE;
     } else {
         PrintStructures = (PRINT_PTRW*) lParam;
-	SetWindowLongA(hDlg, DWL_USER, lParam);
+	SetPropW(hDlg, "__WINE_PRINTDLGDATA", PrintStructures);
 	res = PRINTDLG_WMInitDialogW(hDlg, wParam, PrintStructures);

 	if(PrintStructures->dlg.lpPrintDlg->Flags & PD_ENABLEPRINTHOOK)
-	    res = PrintStructures->dlg.lpPrintDlg->lpfnPrintHook(
-		hDlg, uMsg, wParam, (LPARAM)PrintStructures->dlg.lpPrintDlg
-	    );
+	    res = PrintStructures->dlg.lpPrintDlg->lpfnPrintHook(hDlg, uMsg, wParam, (LPARAM)PrintStructures->dlg.lpPrintDlg);
 	return res;
     }
 
     if(PrintStructures->dlg.lpPrintDlg->Flags & PD_ENABLEPRINTHOOK) {
-        res = PrintStructures->dlg.lpPrintDlg->lpfnPrintHook(hDlg,uMsg,wParam,
-							 lParam);
+        res = PrintStructures->dlg.lpPrintDlg->lpfnPrintHook(hDlg,uMsg,wParam, lParam);
 	if(res) return res;
     }
 


More information about the wine-patches mailing list