X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/75a29298fa900b388cd380649700dc39c9631178..67acaf80e704295df5136538582193ad02c2b927:/src/common/event.cpp?ds=sidebyside diff --git a/src/common/event.cpp b/src/common/event.cpp index 5c65c985af..bda30d8451 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -381,6 +381,11 @@ 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 @@ -397,16 +402,22 @@ 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; } } @@ -1078,22 +1089,14 @@ void wxEvtHandler::AddPendingEvent(wxEvent& event) wxCHECK_RET( eventCopy, _T("events of this type aren't supposed to be posted") ); -#if defined(__VISAGECPP__) - wxENTER_CRIT_SECT( m_eventsLocker); -#else - wxENTER_CRIT_SECT( *m_eventsLocker); -#endif + wxENTER_CRIT_SECT( Lock() ); if ( !m_pendingEvents ) m_pendingEvents = new wxList; m_pendingEvents->Append(eventCopy); -#if defined(__VISAGECPP__) - wxLEAVE_CRIT_SECT( m_eventsLocker); -#else - wxLEAVE_CRIT_SECT( *m_eventsLocker); -#endif + wxLEAVE_CRIT_SECT( Lock() ); // 2) Add this event handler to list of event handlers that // have pending events. @@ -1118,51 +1121,33 @@ void wxEvtHandler::ProcessPendingEvents() wxCHECK_RET( m_pendingEvents, wxT("Please call wxApp::ProcessPendingEvents() instead") ); -#if defined(__VISAGECPP__) - wxENTER_CRIT_SECT( m_eventsLocker); -#else - wxENTER_CRIT_SECT( *m_eventsLocker); -#endif - - // remember last event to process during this iteration - wxList::compatibility_iterator lastPendingNode = m_pendingEvents->GetLast(); + wxENTER_CRIT_SECT( Lock() ); - 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(); + m_pendingEvents->Erase(node); - // In ProcessEvent, new events might get added and - // we can safely leave the crtical section here. -#if defined(__VISAGECPP__) - wxLEAVE_CRIT_SECT( m_eventsLocker); -#else - wxLEAVE_CRIT_SECT( *m_eventsLocker); -#endif + wxLEAVE_CRIT_SECT( Lock() ); + ProcessEvent(*event); delete event; -#if defined(__VISAGECPP__) - wxENTER_CRIT_SECT( m_eventsLocker); -#else - 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; + wxENTER_CRIT_SECT( Lock() ); - node = m_pendingEvents->GetFirst(); + if ( !--n ) + break; } -#if defined(__VISAGECPP__) - wxLEAVE_CRIT_SECT( m_eventsLocker); -#else - wxLEAVE_CRIT_SECT( *m_eventsLocker); -#endif + wxLEAVE_CRIT_SECT( Lock() ); } /*