Francois Gouget : comdlg32: Fix PrintDlg(NULL) and reenable a test that was in an '#if 0'.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Dec 14 14:24:02 CST 2006


Module: wine
Branch: master
Commit: 2c531ade2e106799d382bda6e8c57531170b879b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2c531ade2e106799d382bda6e8c57531170b879b

Author: Francois Gouget <fgouget at free.fr>
Date:   Thu Dec 14 18:13:01 2006 +0100

comdlg32: Fix PrintDlg(NULL) and reenable a test that was in an '#if 0'.

Fix the test so it compiles without warnings.

---

 dlls/comdlg32/printdlg.c       |   26 +++++++++++++++++++-------
 dlls/comdlg32/tests/printdlg.c |    5 +----
 2 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/dlls/comdlg32/printdlg.c b/dlls/comdlg32/printdlg.c
index 6b6a725..85ffe00 100644
--- a/dlls/comdlg32/printdlg.c
+++ b/dlls/comdlg32/printdlg.c
@@ -1994,9 +1994,16 @@ static BOOL PRINTDLG_CreateDCW(LPPRINTDL
 BOOL WINAPI PrintDlgA(LPPRINTDLGA lppd)
 {
     BOOL      bRet = FALSE;
-    LPVOID   ptr;
-    HINSTANCE hInst = (HINSTANCE)GetWindowLongPtrA( lppd->hwndOwner, GWLP_HINSTANCE );
+    LPVOID    ptr;
+    HINSTANCE hInst;
 
+    if (!lppd)
+    {
+        COMDLG32_SetCommDlgExtendedError(CDERR_INITIALIZATION);
+        return FALSE;
+    }
+
+    hInst = (HINSTANCE)GetWindowLongPtrA( lppd->hwndOwner, GWLP_HINSTANCE );
     if(TRACE_ON(commdlg)) {
         char flagstr[1000] = "";
 	const struct pd_flags *pflag = pd_flags;
@@ -2131,14 +2138,19 @@ BOOL WINAPI PrintDlgA(LPPRINTDLGA lppd)
  *
  * See PrintDlgA.
  */
-BOOL WINAPI PrintDlgW(
-		      LPPRINTDLGW lppd /* [in/out] ptr to PRINTDLG32 struct */
-		      )
+BOOL WINAPI PrintDlgW(LPPRINTDLGW lppd)
 {
     BOOL      bRet = FALSE;
-    LPVOID   ptr;
-    HINSTANCE hInst = (HINSTANCE)GetWindowLongPtrW( lppd->hwndOwner, GWLP_HINSTANCE );
+    LPVOID    ptr;
+    HINSTANCE hInst;
+
+    if (!lppd)
+    {
+        COMDLG32_SetCommDlgExtendedError(CDERR_INITIALIZATION);
+        return FALSE;
+    }
 
+    hInst = (HINSTANCE)GetWindowLongPtrW( lppd->hwndOwner, GWLP_HINSTANCE );
     if(TRACE_ON(commdlg)) {
         char flagstr[1000] = "";
 	const struct pd_flags *pflag = pd_flags;
diff --git a/dlls/comdlg32/tests/printdlg.c b/dlls/comdlg32/tests/printdlg.c
index bd3ddf1..0ef12d7 100644
--- a/dlls/comdlg32/tests/printdlg.c
+++ b/dlls/comdlg32/tests/printdlg.c
@@ -46,15 +46,12 @@ static void test_PrintDlgA(void)
     if (!pDlg) return;
 
 
-#if 0
     /* will crash with unpatched wine */
     SetLastError(0xdeadbeef);
     res = PrintDlgA(NULL);
     ok( !res && (CommDlgExtendedError() == CDERR_INITIALIZATION),
-        "returned %ld with 0x%lx and 0x%lx (expected '0' and " \
+        "returned %d with 0x%x and 0x%x (expected '0' and " \
         "CDERR_INITIALIZATION)\n", res, GetLastError(), CommDlgExtendedError());
-    }
-#endif
 
     ZeroMemory(pDlg, sizeof(PRINTDLGA));
     pDlg->lStructSize = sizeof(PRINTDLGA) - 1;




More information about the wine-cvs mailing list