don't wake up on Windows messages when waiting for thread termination in a console application as this results in an infinite loop because we never process them and thus they remain in the queue for always (modified patch 1615875; closes bugs 877128)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44344 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -29,6 +29,9 @@ wxGTK:
|
|||||||
|
|
||||||
- Implemented support for underlined fonts in wxStaticText
|
- Implemented support for underlined fonts in wxStaticText
|
||||||
|
|
||||||
|
wxMSW:
|
||||||
|
|
||||||
|
- Fixed infinite loop in wxThread::Wait() in console applications
|
||||||
|
|
||||||
|
|
||||||
2.8.2
|
2.8.2
|
||||||
|
@@ -40,6 +40,9 @@ public:
|
|||||||
// process a message while waiting for a(nother) thread, should return
|
// process a message while waiting for a(nother) thread, should return
|
||||||
// false if and only if we have to exit the application
|
// false if and only if we have to exit the application
|
||||||
virtual bool DoMessageFromThreadWait() = 0;
|
virtual bool DoMessageFromThreadWait() = 0;
|
||||||
|
|
||||||
|
// wait for the handle to be signaled
|
||||||
|
virtual WXDWORD WaitForThread(WXHANDLE hThread) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _WX_MSW_APPTBASE_H_
|
#endif // _WX_MSW_APPTBASE_H_
|
||||||
|
@@ -24,6 +24,7 @@ public:
|
|||||||
virtual void AfterChildWaitLoop(void *data);
|
virtual void AfterChildWaitLoop(void *data);
|
||||||
|
|
||||||
virtual bool DoMessageFromThreadWait();
|
virtual bool DoMessageFromThreadWait();
|
||||||
|
virtual WXDWORD WaitForThread(WXHANDLE hThread);
|
||||||
};
|
};
|
||||||
|
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
@@ -37,6 +38,7 @@ public:
|
|||||||
|
|
||||||
virtual bool DoMessageFromThreadWait();
|
virtual bool DoMessageFromThreadWait();
|
||||||
virtual wxPortId GetToolkitVersion(int *majVer, int *minVer) const;
|
virtual wxPortId GetToolkitVersion(int *majVer, int *minVer) const;
|
||||||
|
virtual WXDWORD WaitForThread(WXHANDLE hThread);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // wxUSE_GUI
|
#endif // wxUSE_GUI
|
||||||
|
@@ -225,6 +225,19 @@ bool wxGUIAppTraits::DoMessageFromThreadWait()
|
|||||||
return evtLoop->Dispatch();
|
return evtLoop->Dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DWORD wxGUIAppTraits::WaitForThread(WXHANDLE hThread)
|
||||||
|
{
|
||||||
|
return ::MsgWaitForMultipleObjects
|
||||||
|
(
|
||||||
|
1, // number of objects to wait for
|
||||||
|
(HANDLE *)&hThread, // the objects
|
||||||
|
false, // wait for any objects, not all
|
||||||
|
INFINITE, // no timeout
|
||||||
|
QS_ALLINPUT | // return as soon as there are any events
|
||||||
|
QS_ALLPOSTMESSAGE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *majVer, int *minVer) const
|
wxPortId wxGUIAppTraits::GetToolkitVersion(int *majVer, int *minVer) const
|
||||||
{
|
{
|
||||||
OSVERSIONINFO info;
|
OSVERSIONINFO info;
|
||||||
|
@@ -71,3 +71,8 @@ bool wxConsoleAppTraits::DoMessageFromThreadWait()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WXDWORD wxConsoleAppTraits::WaitForThread(WXHANDLE hThread)
|
||||||
|
{
|
||||||
|
return ::WaitForSingleObject((HANDLE)hThread, INFINITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -755,15 +755,16 @@ wxThreadInternal::WaitForTerminate(wxCriticalSection& cs,
|
|||||||
#if !defined(QS_ALLPOSTMESSAGE)
|
#if !defined(QS_ALLPOSTMESSAGE)
|
||||||
#define QS_ALLPOSTMESSAGE 0
|
#define QS_ALLPOSTMESSAGE 0
|
||||||
#endif
|
#endif
|
||||||
|
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
||||||
result = ::MsgWaitForMultipleObjects
|
if ( traits )
|
||||||
(
|
{
|
||||||
1, // number of objects to wait for
|
result = traits->WaitForThread(m_hThread);
|
||||||
&m_hThread, // the objects
|
}
|
||||||
false, // don't wait for all objects
|
else // can't wait for the thread
|
||||||
INFINITE, // no timeout
|
{
|
||||||
QS_ALLINPUT|QS_ALLPOSTMESSAGE // return as soon as there are any events
|
// so kill it below
|
||||||
);
|
result = 0xFFFFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
switch ( result )
|
switch ( result )
|
||||||
{
|
{
|
||||||
@@ -788,9 +789,6 @@ wxThreadInternal::WaitForTerminate(wxCriticalSection& cs,
|
|||||||
// the system might dead lock then
|
// the system might dead lock then
|
||||||
if ( wxThread::IsMain() )
|
if ( wxThread::IsMain() )
|
||||||
{
|
{
|
||||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits()
|
|
||||||
: NULL;
|
|
||||||
|
|
||||||
if ( traits && !traits->DoMessageFromThreadWait() )
|
if ( traits && !traits->DoMessageFromThreadWait() )
|
||||||
{
|
{
|
||||||
// WM_QUIT received: kill the thread
|
// WM_QUIT received: kill the thread
|
||||||
|
Reference in New Issue
Block a user