From: Vadim Zeitlin Date: Sun, 12 Dec 2004 11:44:46 +0000 (+0000) Subject: stop processing pending events after processing all of them which had been in the... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/18dbea4d81abbd97235a1f6548a0710f1c589817 stop processing pending events after processing all of them which had been in the queue when we started, not until there are none as this could result in an infinite loop (part of patch 1080770) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30949 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/event.cpp b/src/common/event.cpp index 2962ea721b..55484498bb 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -1106,6 +1106,9 @@ void wxEvtHandler::ProcessPendingEvents() wxENTER_CRIT_SECT( *m_eventsLocker); #endif + // remember last event to process during this iteration + wxList::compatibility_iterator lastPendingNode = m_pendingEvents->GetLast(); + wxList::compatibility_iterator node = m_pendingEvents->GetFirst(); while ( node ) { @@ -1127,6 +1130,13 @@ void wxEvtHandler::ProcessPendingEvents() wxENTER_CRIT_SECT( *m_eventsLocker); #endif + // leave the loop once we have processed all events that were present + // at the start of ProcessPendingEvents because otherwise we could get + // into infinite loop if the pending event handler execution resulted + // in another event being posted + if ( node == lastPendingNode ) + break; + node = m_pendingEvents->GetFirst(); }