From 031943ac4ca536d38af4951248fbea39c51694df Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 8 Apr 2006 22:51:42 +0000 Subject: [PATCH] changed DoMessageFromThreadWait() to not block if there are no messages, this avoids the need for sending a dummy WM_NULL from the thread wait loop (replaces patch 1459812) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38628 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/app.cpp | 12 +++++++++--- src/msw/thread.cpp | 6 ------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/msw/app.cpp b/src/msw/app.cpp index e071002e1b..e7733b748c 100644 --- a/src/msw/app.cpp +++ b/src/msw/app.cpp @@ -48,6 +48,7 @@ #include "wx/filename.h" #include "wx/module.h" #include "wx/dynlib.h" +#include "wx/evtloop.h" #include "wx/msw/private.h" #include "wx/msw/ole/oleutils.h" @@ -218,7 +219,14 @@ bool wxGUIAppTraits::DoMessageFromThreadWait() { // we should return false only if the app should exit, i.e. only if // Dispatch() determines that the main event loop should terminate - return !wxTheApp || wxTheApp->Dispatch(); + wxEventLoop *evtLoop = wxEventLoop::GetActive(); + if ( !evtLoop || !evtLoop->Pending() ) + { + // no events means no quit event + return true; + } + + return evtLoop->Dispatch(); } wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo() @@ -748,8 +756,6 @@ terminate the program,\r\n\ #if WXWIN_COMPATIBILITY_2_4 -#include "wx/evtloop.h" - void wxApp::DoMessage(WXMSG *pMsg) { wxEventLoop *evtLoop = wxEventLoop::GetActive(); diff --git a/src/msw/thread.cpp b/src/msw/thread.cpp index 30484e2c86..23960ebf94 100644 --- a/src/msw/thread.cpp +++ b/src/msw/thread.cpp @@ -737,12 +737,6 @@ wxThreadInternal::WaitForTerminate(wxCriticalSection& cs, // the system might dead lock then if ( wxThread::IsMain() ) { - // it looks that sometimes WAIT_OBJECT_0 + 1 is - // returned but there are no messages in the thread - // queue -- prevent DoMessageFromThreadWait() from - // blocking inside ::GetMessage() forever in this case - ::PostMessage(NULL, WM_NULL, 0, 0); - wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;