From dbbcfbb642f5dffe1285bd39c41d8c4b3e1164c2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 24 May 2009 19:37:02 +0000 Subject: [PATCH] always dispatch messages for the hidden window which receives process termination notifications; otherwise calling wxExecute(wxEXEC_SYNC) without an active event loop never returns git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60733 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/utilsexc.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/msw/utilsexc.cpp b/src/msw/utilsexc.cpp index aaf6176b1c..5d2e0b52cb 100644 --- a/src/msw/utilsexc.cpp +++ b/src/msw/utilsexc.cpp @@ -38,6 +38,7 @@ #include "wx/process.h" #include "wx/thread.h" #include "wx/apptrait.h" +#include "wx/evtloop.h" #include "wx/vector.h" @@ -1007,8 +1008,19 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler) ::Sleep(50); } - // we must process messages or we'd never get wxWM_PROC_TERMINATED - traits->AlwaysYield(); + // we must always process messages for our hidden window or we'd never + // get wxWM_PROC_TERMINATED and so this loop would never terminate + MSG msg; + ::PeekMessage(&msg, data->hWnd, 0, 0, PM_REMOVE); + + // we may also need to process messages for all the other application + // windows + if ( !(flags & wxEXEC_NOEVENTS) ) + { + wxEventLoopBase * const loop = wxEventLoopBase::GetActive(); + if ( loop ) + loop->Yield(); + } } if ( !(flags & wxEXEC_NODISABLE) ) -- 2.45.2