#endif
#include "wx/dynarray.h"
+#include "wx/thread.h"
// ----------------------------------------------------------------------------
// forward declarations
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_BASE wxList;
-#if wxUSE_THREADS
- class WXDLLIMPEXP_FWD_BASE wxCriticalSection;
-#endif
#if wxUSE_GUI
class WXDLLIMPEXP_FWD_CORE wxDC;
class WXDLLIMPEXP_FWD_CORE wxMenu;
virtual bool SearchEventTable(wxEventTable& table, wxEvent& event);
bool SearchDynamicEventTable( wxEvent& event );
-#if wxUSE_THREADS
- void ClearEventLocker();
-#endif // wxUSE_THREADS
-
// Avoid problems at exit by cleaning up static hash table gracefully
void ClearEventHashTable() { GetEventHashTable().Clear(); }
wxList* m_pendingEvents;
#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
+ // critical section protecting m_pendingEvents
+ wxCriticalSection m_pendingEventsLock;
+#endif // wxUSE_THREADS
// Is event handler enabled?
bool m_enabled;
delete wxTheColourDatabase;
wxTheColourDatabase = NULL;
-#if wxUSE_THREADS
- #if wxUSE_VALIDATORS
- // If we don't do the following, we get an apparent memory leak.
- ((wxEvtHandler&) wxDefaultValidator).ClearEventLocker();
- #endif // wxUSE_VALIDATORS
-#endif // wxUSE_THREADS
-
wxAppConsole::CleanUp();
}
m_enabled = true;
m_dynamicEvents = (wxList *) NULL;
m_pendingEvents = (wxList *) NULL;
-#if wxUSE_THREADS
-# if !defined(__VISAGECPP__)
- m_eventsLocker = new wxCriticalSection;
-# endif
-#endif
// no client data (yet)
m_clientData = NULL;
m_pendingEvents->DeleteContents(true);
delete m_pendingEvents;
-# if !defined(__VISAGECPP__)
- delete m_eventsLocker;
-# endif
-
// Remove us from wxPendingEvents if necessary.
if ( wxPendingEvents )
{
return true;
}
-void wxEvtHandler::ClearEventLocker()
-{
-#if !defined(__VISAGECPP__)
- delete m_eventsLocker;
- m_eventsLocker = NULL;
-#endif
-}
-
#endif // wxUSE_THREADS
void wxEvtHandler::AddPendingEvent(const wxEvent& event)
wxCHECK_RET( eventCopy,
_T("events of this type aren't supposed to be posted") );
- wxENTER_CRIT_SECT( Lock() );
+ wxENTER_CRIT_SECT( m_pendingEventsLock );
if ( !m_pendingEvents )
m_pendingEvents = new wxList;
m_pendingEvents->Append(eventCopy);
- wxLEAVE_CRIT_SECT( Lock() );
+ wxLEAVE_CRIT_SECT( m_pendingEventsLock );
// 2) Add this event handler to list of event handlers that
// have pending events.
void wxEvtHandler::ProcessPendingEvents()
{
- wxENTER_CRIT_SECT( Lock() );
+ wxENTER_CRIT_SECT( m_pendingEventsLock );
// this method is only called by wxApp if this handler does have
// pending events
if ( m_pendingEvents->IsEmpty() )
wxPendingEvents->DeleteObject(this);
- wxLEAVE_CRIT_SECT( Lock() );
+ wxLEAVE_CRIT_SECT( m_pendingEventsLock );
ProcessEvent(*event);