Sleep a bit before bringing window to front
authorAndre Heinecke <aheinecke@intevation.de>
Tue, 10 Apr 2018 11:12:35 +0000 (13:12 +0200)
committerAndre Heinecke <aheinecke@intevation.de>
Tue, 10 Apr 2018 11:12:35 +0000 (13:12 +0200)
* src/common.c (bring_to_front): log when done.
* src/windowmessages.cpp (gpgol_window_proc): Sleep a bit
before bring to front.

--
This might resolve an observed deadlock where setforegroundwindow
would block the UI thread as it tried to bring the disabled
mail window to front. Might also help with:

GnuPG-Bug-Id: T3889

src/common.c
src/windowmessages.cpp

index 6f1ac56..a9ac04b 100644 (file)
@@ -260,6 +260,7 @@ bring_to_front (HWND wid)
             }
         }
     }
+  log_debug ("%s:%s: done", SRCNAME, __func__);
 }
 
 void
index 9d96956..73292d1 100644 (file)
@@ -159,6 +159,9 @@ gpgol_window_proc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
             }
           case (BRING_TO_FRONT):
             {
+              // We want to avoid a race where the mail window
+              // was still the active window.
+              Sleep (250);
               HWND wnd = get_active_hwnd ();
               if (wnd)
                 {