From f30083b9607a2ce964d8b557e621894e2dc4a21e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 2 Feb 2007 23:22:22 +0000 Subject: [PATCH] don't wait for Windows messages in WaitForThread() if we don't dispatch events (should fix the bugs 1523302 and 1650795) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@44346 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/thread.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/msw/thread.cpp b/src/msw/thread.cpp index ee7fec670d..736663b38a 100644 --- a/src/msw/thread.cpp +++ b/src/msw/thread.cpp @@ -755,15 +755,26 @@ wxThreadInternal::WaitForTerminate(wxCriticalSection& cs, #if !defined(QS_ALLPOSTMESSAGE) #define QS_ALLPOSTMESSAGE 0 #endif - - result = ::MsgWaitForMultipleObjects - ( - 1, // number of objects to wait for - &m_hThread, // the objects - false, // don't wait for all objects - INFINITE, // no timeout - QS_ALLINPUT|QS_ALLPOSTMESSAGE // return as soon as there are any events - ); + if ( !wxEventLoop::GetActive() ) + { + // don't ask for Windows messages if we don't have a running event + // loop to process them as otherwise we'd enter an infinite loop + // with MsgWaitForMultipleObjects() always returning WAIT_OBJECT_0 + // + 1 because the message would remain forever in the queue + result = ::WaitForSingleObject(&m_hThread, INFINITE); + } + else // wait for thread termination without blocking the GUI + { + result = ::MsgWaitForMultipleObjects + ( + 1, // number of objects to wait for + &m_hThread, // the objects + false, // don't wait for all objects + INFINITE, // no timeout + QS_ALLINPUT | // return as soon as there are any events + QS_ALLPOSTMESSAGE + ); + } switch ( result ) {