]> git.saurik.com Git - wxWidgets.git/commitdiff
stop processing pending events after processing all of them which had been in the...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 12 Dec 2004 11:44:46 +0000 (11:44 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 12 Dec 2004 11:44:46 +0000 (11:44 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30949 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/event.cpp

index 2962ea721b2e10b9df2eed6b1464bb1e487430b0..55484498bb2926adc534c3a046e795e75e228ead 100644 (file)
@@ -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();
     }