X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8bd9fa338ed307031e4c1a43308210205f9a6384..fec34ef52dad898e72dd488f939ea0db5ec09ead:/src/common/evtloopcmn.cpp diff --git a/src/common/evtloopcmn.cpp b/src/common/evtloopcmn.cpp index dc42cdbf02..863946f59d 100644 --- a/src/common/evtloopcmn.cpp +++ b/src/common/evtloopcmn.cpp @@ -9,14 +9,6 @@ // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - // for compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -24,15 +16,14 @@ #pragma hdrstop #endif +#include "wx/evtloop.h" + #ifndef WX_PRECOMP #include "wx/app.h" - #include "wx/event.h" #endif //WX_PRECOMP -#include "wx/evtloop.h" - // ---------------------------------------------------------------------------- -// globals +// wxEventLoopBase // ---------------------------------------------------------------------------- wxEventLoopBase *wxEventLoopBase::ms_activeLoop = NULL; @@ -43,6 +34,28 @@ wxEventLoopBase::wxEventLoopBase() m_eventsToProcessInsideYield = wxEVT_CATEGORY_ALL; } +bool wxEventLoopBase::IsMain() const +{ + if (wxTheApp) + return wxTheApp->GetMainLoop() == this; + return false; +} + +/* static */ +void wxEventLoopBase::SetActive(wxEventLoopBase* loop) +{ + ms_activeLoop = loop; + + if (wxTheApp) + wxTheApp->OnEventLoopEnter(loop); +} + +void wxEventLoopBase::OnExit() +{ + if (wxTheApp) + wxTheApp->OnEventLoopExit(this); +} + void wxEventLoopBase::DelayPendingEventHandler(wxEvtHandler* toDelay) { wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker); @@ -128,7 +141,7 @@ void wxEventLoopBase::ProcessPendingEvents() { // In ProcessPendingEvents(), new handlers might be added // and we can safely leave the critical section here. - wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker); + wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker); // NOTE: we always call ProcessPendingEvents() on the first event handler // with pending events because handlers auto-remove themselves @@ -136,7 +149,7 @@ void wxEventLoopBase::ProcessPendingEvents() // more pending events. m_handlersWithPendingEvents[0]->ProcessPendingEvents(); - wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker); + wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker); } // now the wxHandlersWithPendingEvents is surely empty; however some event