]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0207: MS-Windows: freeze on second :hardcopy v9.2.0207
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Thu, 19 Mar 2026 21:40:25 +0000 (21:40 +0000)
committerChristian Brabandt <cb@256bit.org>
Thu, 19 Mar 2026 21:44:01 +0000 (21:44 +0000)
Problem:  MS-Windows: freeze on second :hardcopy
          (antoniopaolini)
Solution: Enable PrintHookProc in GUI mode to ensure the print dialog is
          brought to the foreground (Yasuhiro Matsumoto).

Enable PrintHookProc for GUI mode so that the print dialog is brought
to the foreground via BringWindowToTop/SetForegroundWindow.  Without
the hook, the second PrintDlgW() modal dialog appears behind gvim due
to Windows foreground lock timeout, making gvim unresponsive.

Also add NULL checks for hDlgPrint in SendMessage calls.

fixes:  #19715
closes: #19754

Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/os_mswin.c
src/version.c

index 89e4d1c4dd07f834c13f56312fb83b820577d829..6c92428a0adfca6ad4ad640a344c5ddce29990df 100644 (file)
@@ -1192,8 +1192,6 @@ AbortProc(HDC hdcPrn UNUSED, int iCode UNUSED)
     return !*bUserAbort;
 }
 
-# if !defined(FEAT_GUI) || defined(VIMDLL)
-
     static UINT_PTR CALLBACK
 PrintHookProc(
        HWND hDlg,      // handle to dialog box
@@ -1246,7 +1244,6 @@ PrintHookProc(
 
     return FALSE;
 }
-# endif
 
     void
 mch_print_cleanup(void)
@@ -1262,7 +1259,7 @@ mch_print_cleanup(void)
 
     if (prt_dlg.hDC != NULL)
        DeleteDC(prt_dlg.hDC);
-    if (!*bUserAbort)
+    if (!*bUserAbort && hDlgPrint != NULL)
        SendMessage(hDlgPrint, WM_COMMAND, 0, 0);
 }
 
@@ -1400,18 +1397,11 @@ mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
        prt_dlg.hDevMode = stored_dm;
        prt_dlg.hDevNames = stored_devn;
        prt_dlg.lCustData = stored_nCopies; // work around bug in print dialog
-# if !defined(FEAT_GUI) || defined(VIMDLL)
-#  ifdef VIMDLL
-       if (!gui.in_use)
-#  endif
-       {
-           /*
-            * Use hook to prevent console window being sent to back
-            */
-           prt_dlg.lpfnPrintHook = PrintHookProc;
-           prt_dlg.Flags |= PD_ENABLEPRINTHOOK;
-       }
-# endif
+       /*
+        * Use hook to prevent print dialog being sent to back.
+        */
+       prt_dlg.lpfnPrintHook = PrintHookProc;
+       prt_dlg.Flags |= PD_ENABLEPRINTHOOK;
        prt_dlg.Flags |= stored_nFlags;
     }
 
@@ -1628,7 +1618,7 @@ mch_print_begin(prt_settings_T *psettings)
 mch_print_end(prt_settings_T *psettings UNUSED)
 {
     EndDoc(prt_dlg.hDC);
-    if (!*bUserAbort)
+    if (!*bUserAbort && hDlgPrint != NULL)
        SendMessage(hDlgPrint, WM_COMMAND, 0, 0);
 }
 
index 6914a9b5ddc87c16d9efb4abe601eedb8a00957e..7482aa8b7199525c64ac76a58646c1b30a1bf469 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    207,
 /**/
     206,
 /**/