From: Vadim Zeitlin Date: Tue, 1 Mar 2005 01:21:04 +0000 (+0000) Subject: added accessor function to hide __VISAGECPP__ ugliness and avoid having #ifdef's... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/cd30330fc67d0fe32f325ab16f2764cbd90d24af added accessor function to hide __VISAGECPP__ ugliness and avoid having #ifdef's for it every other line git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32506 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/event.h b/include/wx/event.h index 7d82d855a3..93b515af2b 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -2417,8 +2417,14 @@ protected: #if wxUSE_THREADS #if defined (__VISAGECPP__) + const wxCriticalSection& Lock() const { return m_eventsLocker; } + wxCriticalSection& Lock() { return m_eventsLocker; } + wxCriticalSection m_eventsLocker; # else + const wxCriticalSection& Lock() const { return *m_eventsLocker; } + wxCriticalSection& Lock() { return *m_eventsLocker; } + wxCriticalSection* m_eventsLocker; # endif #endif diff --git a/src/common/event.cpp b/src/common/event.cpp index bab410244b..da707a1887 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -1089,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. @@ -1129,11 +1121,7 @@ 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 + wxENTER_CRIT_SECT( Lock() ); // remember last event to process during this iteration wxList::compatibility_iterator lastPendingNode = m_pendingEvents->GetLast(); @@ -1146,18 +1134,10 @@ void wxEvtHandler::ProcessPendingEvents() // 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 + 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 @@ -1169,11 +1149,7 @@ void wxEvtHandler::ProcessPendingEvents() node = m_pendingEvents->GetFirst(); } -#if defined(__VISAGECPP__) - wxLEAVE_CRIT_SECT( m_eventsLocker); -#else - wxLEAVE_CRIT_SECT( *m_eventsLocker); -#endif + wxLEAVE_CRIT_SECT( Lock() ); } /*