]> git.saurik.com Git - wxWidgets.git/commitdiff
fixed problems with sometimes processing the events twice introduced in rev 1.170...
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 2 Dec 2005 00:53:31 +0000 (00:53 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 2 Dec 2005 00:53:31 +0000 (00:53 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36330 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/event.cpp

index 7597499232985719077b41fe35dad7bd35e7354e..8b74ef2a817b5f275b1561070a5894c5a18df4d1 100644 (file)
@@ -1023,6 +1023,8 @@ wxEvtHandler::~wxEvtHandler()
         delete m_dynamicEvents;
     };
 
+    if (m_pendingEvents)
+        m_pendingEvents->DeleteContents(true);
     delete m_pendingEvents;
 
 #if wxUSE_THREADS
@@ -1084,10 +1086,7 @@ void wxEvtHandler::AddPendingEvent(wxEvent& event)
     wxENTER_CRIT_SECT( Lock() );
 
     if ( !m_pendingEvents )
-    {
       m_pendingEvents = new wxList;
-      m_pendingEvents->DeleteContents(true);
-    }
 
     m_pendingEvents->Append(eventCopy);
 
@@ -1129,14 +1128,18 @@ void wxEvtHandler::ProcessPendingEvents()
     {
         wxEvent *event = (wxEvent *)node->GetData();
 
+        // It's importan we remove event from list before processing it.
+        // Else a nested event loop, for example from a modal dialog, might
+        // process the same event again.
+        m_pendingEvents->Erase(node);
+
         wxLEAVE_CRIT_SECT( Lock() );
 
         ProcessEvent(*event);
+        delete event;
 
         wxENTER_CRIT_SECT( Lock() );
 
-        m_pendingEvents->Erase(node);
-
         if ( !--n )
             break;
     }