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(); }