X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b568d04ffa191f9e3b643ca33526094eca0ba304..e15421ad3b12cbcbf4f1d5abfb153b00a7018bb8:/src/common/appcmn.cpp diff --git a/src/common/appcmn.cpp b/src/common/appcmn.cpp index 3276436a6e..d185f5bff0 100644 --- a/src/common/appcmn.cpp +++ b/src/common/appcmn.cpp @@ -47,22 +47,31 @@ void wxAppBase::ProcessPendingEvents() { // ensure that we're the only thread to modify the pending events list - wxCRIT_SECT_LOCKER(locker, *wxPendingEventsLocker); + wxENTER_CRIT_SECT( *wxPendingEventsLocker ); if ( !wxPendingEvents ) + { + wxLEAVE_CRIT_SECT( *wxPendingEventsLocker ); return; + } // iterate until the list becomes empty wxNode *node = wxPendingEvents->First(); while (node) { wxEvtHandler *handler = (wxEvtHandler *)node->Data(); + delete node; + // In ProcessPendingEvents(), new handlers might be add + // and we can safely leave the critical section here. + wxLEAVE_CRIT_SECT( *wxPendingEventsLocker ); handler->ProcessPendingEvents(); + wxENTER_CRIT_SECT( *wxPendingEventsLocker ); - delete node; node = wxPendingEvents->First(); } + + wxLEAVE_CRIT_SECT( *wxPendingEventsLocker ); } int wxAppBase::OnExit()