]> git.saurik.com Git - wxWidgets.git/commitdiff
fix HasPendingEvents() to only return true if there are actually events pending
authorPaul Cornett <paulcor@bullseye.com>
Sat, 14 Jul 2007 18:18:22 +0000 (18:18 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Sat, 14 Jul 2007 18:18:22 +0000 (18:18 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47463 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/appbase.cpp

index 119622bb8b164ae5d9c9fae44617dd027ffc0456..4cf7d8c3c898fdddf37bd17c61139cd50a1f5b4d 100644 (file)
@@ -330,16 +330,13 @@ bool wxAppConsoleBase::Dispatch()
 
 bool wxAppConsoleBase::HasPendingEvents() const
 {
-    // ensure that we're the only thread to modify the pending events list
     wxENTER_CRIT_SECT( *wxPendingEventsLocker );
 
-    if ( !wxPendingEvents )
-    {
-        wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
-        return false;
-    }
+    bool has = wxPendingEvents && !wxPendingEvents->IsEmpty();
+
     wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
-    return true;
+
+    return has;
 }
 
 /* static */
@@ -357,27 +354,27 @@ void wxAppConsoleBase::ProcessPendingEvents()
         return;
 #endif
 
-    if ( !HasPendingEvents() )
-        return;
-
     wxENTER_CRIT_SECT( *wxPendingEventsLocker );
 
-    // iterate until the list becomes empty
-    wxList::compatibility_iterator node = wxPendingEvents->GetFirst();
-    while (node)
+    if (wxPendingEvents)
     {
-        wxEvtHandler *handler = (wxEvtHandler *)node->GetData();
-        wxPendingEvents->Erase(node);
+        // iterate until the list becomes empty
+        wxList::compatibility_iterator node = wxPendingEvents->GetFirst();
+        while (node)
+        {
+            wxEvtHandler *handler = (wxEvtHandler *)node->GetData();
+            wxPendingEvents->Erase(node);
 
-        // In ProcessPendingEvents(), new handlers might be add
-        // and we can safely leave the critical section here.
-        wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
+            // In ProcessPendingEvents(), new handlers might be add
+            // and we can safely leave the critical section here.
+            wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );
 
-        handler->ProcessPendingEvents();
+            handler->ProcessPendingEvents();
 
-        wxENTER_CRIT_SECT( *wxPendingEventsLocker );
+            wxENTER_CRIT_SECT( *wxPendingEventsLocker );
 
-        node = wxPendingEvents->GetFirst();
+            node = wxPendingEvents->GetFirst();
+        }
     }
 
     wxLEAVE_CRIT_SECT( *wxPendingEventsLocker );