Refactor YieldFor() to avoid code duplication among the ports.

Don't repeat the same code in all the ports, move it to the common base class
and add a new virtual DoYieldFor() for the really port-specific code.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76061 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-03-02 18:58:00 +00:00
parent 632c106cd5
commit f740cc3881
19 changed files with 97 additions and 199 deletions

View File

@@ -116,6 +116,49 @@ bool wxEventLoopBase::Yield(bool onlyIfNeeded)
return YieldFor(wxEVT_CATEGORY_ALL);
}
bool wxEventLoopBase::YieldFor(long eventsToProcess)
{
#if wxUSE_THREADS
if ( !wxThread::IsMain() )
{
// Don't ever dispatch events from non-main threads.
return false;
}
#endif // wxUSE_THREADS
// set the flag and don't forget to reset it before returning
m_isInsideYield = true;
m_eventsToProcessInsideYield = eventsToProcess;
wxON_BLOCK_EXIT_SET(m_isInsideYield, false);
#if wxUSE_LOG
// disable log flushing from here because a call to wxYield() shouldn't
// normally result in message boxes popping up &c
wxLog::Suspend();
// ensure the logs will be flashed again when we exit
wxON_BLOCK_EXIT0(wxLog::Resume);
#endif
DoYieldFor(eventsToProcess);
return true;
}
void wxEventLoopBase::DoYieldFor(long eventsToProcess)
{
// Normally yielding dispatches not only the pending native events, but
// also the events pending in wxWidgets itself.
//
// Notice however that we must not do it if we're asked to process only the
// events of specific kind, as pending events could be of any kind at all
// (ideal would be to have a filtering version of ProcessPendingEvents()
// too but we don't have this right now).
if ( eventsToProcess == wxEVT_CATEGORY_ALL && wxTheApp )
wxTheApp->ProcessPendingEvents();
}
#if wxUSE_EVENTLOOP_SOURCE
wxEventLoopSource*