]> git.saurik.com Git - wxWidgets.git/commitdiff
added accessor function to hide __VISAGECPP__ ugliness and avoid having #ifdef's...
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 1 Mar 2005 01:21:04 +0000 (01:21 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 1 Mar 2005 01:21:04 +0000 (01:21 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32506 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/event.h
src/common/event.cpp

index 7d82d855a325c0aade6bbe44c5aac852a1988178..93b515af2b02161f06e1275a2ff82f45cf55a8ef 100644 (file)
@@ -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
index bab410244b6e3799296b279321e431cab39fec1b..da707a18872f29a3cea4e7a1edf7f7678e9267f7 100644 (file)
@@ -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() );
 }
 
 /*