X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/90e572f1e5af1e51fd14e2e1e6f64fa3e258e590..713d1441451812a290a4285c7aa2bf1fb020ea6e:/src/common/event.cpp diff --git a/src/common/event.cpp b/src/common/event.cpp index 7597499232..8b74ef2a81 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -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; }