X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1a18887b88e2ba064154ae5998db7b7533f6bb78..d1fabc121183800c237c8a1949494ea634c6796f:/src/common/event.cpp diff --git a/src/common/event.cpp b/src/common/event.cpp index 2962ea721b..bab410244b 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -44,6 +44,7 @@ #include "wx/control.h" #include "wx/utils.h" #include "wx/dc.h" + #include "wx/textctrl.h" #endif // wxUSE_GUI #endif @@ -380,8 +381,16 @@ wxEvent::wxEvent(const wxEvent &src) * */ +#ifdef __VISUALC__ + // 'this' : used in base member initializer list (for m_commandString) + #pragma warning(disable:4355) +#endif + wxCommandEvent::wxCommandEvent(wxEventType commandType, int theId) : wxEvent(theId, commandType) +#if WXWIN_COMPATIBILITY_2_4 + , m_commandString(this) +#endif { m_clientData = (char *) NULL; m_clientObject = (wxClientData *) NULL; @@ -393,6 +402,26 @@ wxCommandEvent::wxCommandEvent(wxEventType commandType, int theId) m_propagationLevel = wxEVENT_PROPAGATE_MAX; } +#ifdef __VISUALC__ + #pragma warning(default:4355) +#endif + +wxString wxCommandEvent::GetString() const +{ + if(m_eventType != wxEVT_COMMAND_TEXT_UPDATED || !m_eventObject) + return m_cmdString; + else + { +#if wxUSE_TEXTCTRL + wxTextCtrl *txt = wxDynamicCast(m_eventObject, wxTextCtrl); + if(txt) + return txt->GetValue(); + else +#endif // wxUSE_TEXTCTRL + return m_cmdString; + } +} + /* * UI update events */ @@ -1106,6 +1135,9 @@ void wxEvtHandler::ProcessPendingEvents() wxENTER_CRIT_SECT( *m_eventsLocker); #endif + // remember last event to process during this iteration + wxList::compatibility_iterator lastPendingNode = m_pendingEvents->GetLast(); + wxList::compatibility_iterator node = m_pendingEvents->GetFirst(); while ( node ) { @@ -1127,6 +1159,13 @@ void wxEvtHandler::ProcessPendingEvents() wxENTER_CRIT_SECT( *m_eventsLocker); #endif + // 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 ) + break; + node = m_pendingEvents->GetFirst(); } @@ -1335,7 +1374,7 @@ bool wxEvtHandler::SearchDynamicEventTable( wxEvent& event ) wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)node->GetData(); #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES - if ((event.m_eventType == entry->m_eventType) && (entry->m_fn != 0)) + if ((event.GetEventType() == entry->m_eventType) && (entry->m_fn != 0)) { wxEvtHandler *handler = #if !WXWIN_COMPATIBILITY_EVENT_TYPES