X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/90e572f1e5af1e51fd14e2e1e6f64fa3e258e590..3abb199dee0afdeae31bac69186751a02a37611e:/src/common/event.cpp diff --git a/src/common/event.cpp b/src/common/event.cpp index 7597499232..a4f85d7d61 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: event.cpp +// Name: src/common/event.cpp // Purpose: Event classes // Author: Julian Smart // Modified by: @@ -25,7 +25,6 @@ #endif #ifndef WX_PRECOMP - #include "wx/defs.h" #include "wx/app.h" #include "wx/list.h" @@ -737,10 +736,12 @@ wxKeyEvent::wxKeyEvent(const wxKeyEvent& evt) #endif } +#if WXWIN_COMPATIBILITY_2_6 long wxKeyEvent::KeyCode() const { return m_keyCode; } +#endif // WXWIN_COMPATIBILITY_2_6 wxWindowCreateEvent::wxWindowCreateEvent(wxWindow *win) { @@ -1023,6 +1024,8 @@ wxEvtHandler::~wxEvtHandler() delete m_dynamicEvents; }; + if (m_pendingEvents) + m_pendingEvents->DeleteContents(true); delete m_pendingEvents; #if wxUSE_THREADS @@ -1084,10 +1087,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,15 +1129,19 @@ 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 ) + if ( --n == 0 ) break; } @@ -1342,6 +1346,10 @@ bool wxEvtHandler::SearchDynamicEventTable( wxEvent& event ) wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)node->GetData(); #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES + // get next node before (maybe) calling the event handler as it could + // call Disconnect() invalidating the current node + node = node->GetNext(); + if ((event.GetEventType() == entry->m_eventType) && (entry->m_fn != 0)) { wxEvtHandler *handler = @@ -1356,8 +1364,6 @@ bool wxEvtHandler::SearchDynamicEventTable( wxEvent& event ) return true; } } - - node = node->GetNext(); } return false;