Ensure that wxApp::Yield is always processing pending event by creating a
temporary event loop if needed. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@53607 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -198,4 +198,32 @@ private:
|
|||||||
wxEventLoop *m_evtLoopOld;
|
wxEventLoop *m_evtLoopOld;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if wxABI_VERSION >= 20808
|
||||||
|
class wxEventLoopGuarantor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxEventLoopGuarantor()
|
||||||
|
{
|
||||||
|
m_evtLoopNew = NULL;
|
||||||
|
if (!wxEventLoop::GetActive())
|
||||||
|
{
|
||||||
|
m_evtLoopNew = new wxEventLoop;
|
||||||
|
wxEventLoop::SetActive(m_evtLoopNew);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
~wxEventLoopGuarantor()
|
||||||
|
{
|
||||||
|
if (m_evtLoopNew)
|
||||||
|
{
|
||||||
|
wxEventLoop::SetActive(NULL);
|
||||||
|
delete m_evtLoopNew;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxEventLoop *m_evtLoopNew;
|
||||||
|
};
|
||||||
|
#endif // wxABI_VERSION >= 20805
|
||||||
|
|
||||||
#endif // _WX_EVTLOOP_H_
|
#endif // _WX_EVTLOOP_H_
|
||||||
|
@@ -137,8 +137,9 @@ bool wxApp::Yield(bool onlyIfNeeded)
|
|||||||
|
|
||||||
wxLog::Suspend();
|
wxLog::Suspend();
|
||||||
|
|
||||||
if ( wxEventLoop::GetActive() )
|
// A guarentee that there will be an active event loop:
|
||||||
wxEventLoop::GetActive()->Yield();
|
wxEventLoopGuarantor dummyLoopIfNeeded;
|
||||||
|
wxEventLoop::GetActive()->Yield();
|
||||||
|
|
||||||
// it's necessary to call ProcessIdle() to update the frames sizes which
|
// it's necessary to call ProcessIdle() to update the frames sizes which
|
||||||
// might have been changed (it also will update other things set from
|
// might have been changed (it also will update other things set from
|
||||||
|
@@ -74,11 +74,10 @@ bool wxApp::Yield(bool onlyIfNeeded)
|
|||||||
|
|
||||||
wxLog::Suspend();
|
wxLog::Suspend();
|
||||||
|
|
||||||
if ( wxEventLoop::GetActive() )
|
// A guarentee that there will be an active event loop:
|
||||||
{
|
wxEventLoopGuarantor dummyLoopIfNeeded;
|
||||||
while (wxEventLoop::GetActive()->Pending())
|
while (wxEventLoop::GetActive()->Pending())
|
||||||
wxEventLoop::GetActive()->Dispatch();
|
wxEventLoop::GetActive()->Dispatch();
|
||||||
}
|
|
||||||
|
|
||||||
/* it's necessary to call ProcessIdle() to update the frames sizes which
|
/* it's necessary to call ProcessIdle() to update the frames sizes which
|
||||||
might have been changed (it also will update other things set from
|
might have been changed (it also will update other things set from
|
||||||
|
@@ -437,6 +437,7 @@ bool wxApp::Yield(bool onlyIfNeeded)
|
|||||||
|
|
||||||
s_inYield = true;
|
s_inYield = true;
|
||||||
|
|
||||||
|
wxEventLoopGuarantor dummyLoopIfNeeded;
|
||||||
while (wxTheApp && wxTheApp->Pending())
|
while (wxTheApp && wxTheApp->Pending())
|
||||||
wxTheApp->Dispatch();
|
wxTheApp->Dispatch();
|
||||||
|
|
||||||
|
@@ -702,6 +702,7 @@ bool wxApp::Yield(bool onlyIfNeeded)
|
|||||||
|
|
||||||
// we don't want to process WM_QUIT from here - it should be processed in
|
// we don't want to process WM_QUIT from here - it should be processed in
|
||||||
// the main event loop in order to stop it
|
// the main event loop in order to stop it
|
||||||
|
wxEventLoopGuarantor dummyLoopIfNeeded;
|
||||||
MSG msg;
|
MSG msg;
|
||||||
while ( PeekMessage(&msg, (HWND)0, 0, 0, PM_NOREMOVE) &&
|
while ( PeekMessage(&msg, (HWND)0, 0, 0, PM_NOREMOVE) &&
|
||||||
msg.message != WM_QUIT )
|
msg.message != WM_QUIT )
|
||||||
|
@@ -551,6 +551,7 @@ bool wxApp::Yield(bool onlyIfNeeded)
|
|||||||
// We want to go back to the main message loop
|
// We want to go back to the main message loop
|
||||||
// if we see a WM_QUIT. (?)
|
// if we see a WM_QUIT. (?)
|
||||||
//
|
//
|
||||||
|
wxEventLoopGuarantor dummyLoopIfNeeded;
|
||||||
while (::WinPeekMsg(vHab, &vMsg, (HWND)NULL, 0, 0, PM_NOREMOVE) && vMsg.msg != WM_QUIT)
|
while (::WinPeekMsg(vHab, &vMsg, (HWND)NULL, 0, 0, PM_NOREMOVE) && vMsg.msg != WM_QUIT)
|
||||||
{
|
{
|
||||||
#if wxUSE_THREADS
|
#if wxUSE_THREADS
|
||||||
|
@@ -796,13 +796,7 @@ bool wxApp::Yield(bool onlyIfNeeded)
|
|||||||
|
|
||||||
// Make sure we have an event loop object,
|
// Make sure we have an event loop object,
|
||||||
// or Pending/Dispatch will fail
|
// or Pending/Dispatch will fail
|
||||||
wxEventLoop* eventLoop = wxEventLoop::GetActive();
|
wxEventLoopGuarantor dummyLoopIfNeeded;
|
||||||
wxEventLoop* newEventLoop = NULL;
|
|
||||||
if (!eventLoop)
|
|
||||||
{
|
|
||||||
newEventLoop = new wxEventLoop;
|
|
||||||
wxEventLoop::SetActive(newEventLoop);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Call dispatch at least once so that sockets
|
// Call dispatch at least once so that sockets
|
||||||
// can be tested
|
// can be tested
|
||||||
@@ -816,12 +810,6 @@ bool wxApp::Yield(bool onlyIfNeeded)
|
|||||||
#endif
|
#endif
|
||||||
ProcessIdle();
|
ProcessIdle();
|
||||||
|
|
||||||
if (newEventLoop)
|
|
||||||
{
|
|
||||||
wxEventLoop::SetActive(NULL);
|
|
||||||
delete newEventLoop;
|
|
||||||
}
|
|
||||||
|
|
||||||
s_inYield = false;
|
s_inYield = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
*TimeZone*Make*;
|
*TimeZone*Make*;
|
||||||
*wxBitmapButton*OnFocusChange*;
|
*wxBitmapButton*OnFocusChange*;
|
||||||
*wxDocManager*MakeNewDocumentName*;
|
*wxDocManager*MakeNewDocumentName*;
|
||||||
|
*wxEventLoopGuarantor*;
|
||||||
*wxGridBagSizer*AdjustForOverflow*;
|
*wxGridBagSizer*AdjustForOverflow*;
|
||||||
*wxRemotelyScrolledTreeCtrl*DoCalcScrolledPosition*;
|
*wxRemotelyScrolledTreeCtrl*DoCalcScrolledPosition*;
|
||||||
*wxRemotelyScrolledTreeCtrl*SetScrollbar*;
|
*wxRemotelyScrolledTreeCtrl*SetScrollbar*;
|
||||||
|
Reference in New Issue
Block a user