X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6dc2a916dfa34137434a17ba7d89d875d17ebbc9..abb4f9c93715f5b00c526203af96ed2938a1a2c3:/src/common/event.cpp?ds=sidebyside diff --git a/src/common/event.cpp b/src/common/event.cpp index ec31583f0d..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); @@ -1104,7 +1103,7 @@ void wxEvtHandler::AddPendingEvent(wxEvent& event) wxLEAVE_CRIT_SECT(*wxPendingEventsLocker); - // 3) Inform the system that new pending events are somwehere, + // 3) Inform the system that new pending events are somewhere, // and that these should be processed in idle time. wxWakeUpIdle(); } @@ -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; }