X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cd30330fc67d0fe32f325ab16f2764cbd90d24af..7ef2db2570c8abd3b472ac91df5035534948c09f:/src/common/event.cpp diff --git a/src/common/event.cpp b/src/common/event.cpp index da707a1887..6da2424443 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: @@ -17,17 +17,6 @@ // headers // ---------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) && !defined(__EMX__) -// Some older compilers (such as EMX) cannot handle -// #pragma interface/implementation correctly, iff -// #pragma implementation is used in _two_ translation -// units (as created by e.g. event.cpp compiled for -// libwx_base and event.cpp compiled for libwx_gui_core). -// So we must not use those pragmas for those compilers in -// such files. - #pragma implementation "event.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -36,7 +25,6 @@ #endif #ifndef WX_PRECOMP - #include "wx/defs.h" #include "wx/app.h" #include "wx/list.h" @@ -245,7 +233,7 @@ DEFINE_EVENT_TYPE(wxEVT_SCROLL_PAGEUP) DEFINE_EVENT_TYPE(wxEVT_SCROLL_PAGEDOWN) DEFINE_EVENT_TYPE(wxEVT_SCROLL_THUMBTRACK) DEFINE_EVENT_TYPE(wxEVT_SCROLL_THUMBRELEASE) -DEFINE_EVENT_TYPE(wxEVT_SCROLL_ENDSCROLL) +DEFINE_EVENT_TYPE(wxEVT_SCROLL_CHANGED) // Scroll events from wxWindow DEFINE_EVENT_TYPE(wxEVT_SCROLLWIN_TOP) @@ -265,6 +253,7 @@ DEFINE_EVENT_TYPE(wxEVT_MOVING) DEFINE_EVENT_TYPE(wxEVT_CLOSE_WINDOW) DEFINE_EVENT_TYPE(wxEVT_END_SESSION) DEFINE_EVENT_TYPE(wxEVT_QUERY_END_SESSION) +DEFINE_EVENT_TYPE(wxEVT_HIBERNATE) DEFINE_EVENT_TYPE(wxEVT_ACTIVATE_APP) DEFINE_EVENT_TYPE(wxEVT_POWER) DEFINE_EVENT_TYPE(wxEVT_ACTIVATE) @@ -1033,6 +1022,8 @@ wxEvtHandler::~wxEvtHandler() delete m_dynamicEvents; }; + if (m_pendingEvents) + m_pendingEvents->DeleteContents(true); delete m_pendingEvents; #if wxUSE_THREADS @@ -1043,8 +1034,10 @@ wxEvtHandler::~wxEvtHandler() // Remove us from wxPendingEvents if necessary. if(wxPendingEventsLocker) wxENTER_CRIT_SECT(*wxPendingEventsLocker); - if ( wxPendingEvents ) { - wxPendingEvents->DeleteObject(this); + if ( wxPendingEvents ) + { + // Delete all occurences of this from the list of pending events + while (wxPendingEvents->DeleteObject(this)) { } // Do nothing } if(wxPendingEventsLocker) wxLEAVE_CRIT_SECT(*wxPendingEventsLocker); @@ -1074,7 +1067,7 @@ void wxEvtHandler::ClearEventLocker() delete m_eventsLocker; m_eventsLocker = NULL; #endif -}; +} #endif // wxUSE_THREADS @@ -1109,7 +1102,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(); } @@ -1123,30 +1116,31 @@ void wxEvtHandler::ProcessPendingEvents() wxENTER_CRIT_SECT( Lock() ); - // remember last event to process during this iteration - wxList::compatibility_iterator lastPendingNode = m_pendingEvents->GetLast(); - - wxList::compatibility_iterator node = m_pendingEvents->GetFirst(); - while ( node ) + // we leave the loop once we have processed all events that were present at + // the start of ProcessPendingEvents because otherwise we could get into + // infinite loop if the pending event handler execution resulted in another + // event being posted + size_t n = m_pendingEvents->size(); + for ( wxList::compatibility_iterator node = m_pendingEvents->GetFirst(); + node; + node = m_pendingEvents->GetFirst() ) { 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); - // In ProcessEvent, new events might get added and - // we can safely leave the crtical section here. wxLEAVE_CRIT_SECT( Lock() ); + ProcessEvent(*event); delete event; + wxENTER_CRIT_SECT( Lock() ); - // leave the loop once we have processed all events that were present - // at the start of ProcessPendingEvents because otherwise we could get - // into infinite loop if the pending event handler execution resulted - // in another event being posted - if ( node == lastPendingNode ) + if ( --n == 0 ) break; - - node = m_pendingEvents->GetFirst(); } wxLEAVE_CRIT_SECT( Lock() ); @@ -1369,7 +1363,7 @@ bool wxEvtHandler::SearchDynamicEventTable( wxEvent& event ) } return false; -}; +} void wxEvtHandler::DoSetClientObject( wxClientData *data ) {