clean up wxEvtHandler::m_eventsLocker weirdness: there is no need to allocate it dynamically (as it's always done anyhow), this removes the need for ClearEventLocker() and OS/2 #ifdefs
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51027 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -23,15 +23,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/dynarray.h"
|
#include "wx/dynarray.h"
|
||||||
|
#include "wx/thread.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// forward declarations
|
// forward declarations
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLIMPEXP_FWD_BASE wxList;
|
class WXDLLIMPEXP_FWD_BASE wxList;
|
||||||
#if wxUSE_THREADS
|
|
||||||
class WXDLLIMPEXP_FWD_BASE wxCriticalSection;
|
|
||||||
#endif
|
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
class WXDLLIMPEXP_FWD_CORE wxDC;
|
class WXDLLIMPEXP_FWD_CORE wxDC;
|
||||||
class WXDLLIMPEXP_FWD_CORE wxMenu;
|
class WXDLLIMPEXP_FWD_CORE wxMenu;
|
||||||
@@ -2359,10 +2357,6 @@ public:
|
|||||||
virtual bool SearchEventTable(wxEventTable& table, wxEvent& event);
|
virtual bool SearchEventTable(wxEventTable& table, wxEvent& event);
|
||||||
bool SearchDynamicEventTable( 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
|
// Avoid problems at exit by cleaning up static hash table gracefully
|
||||||
void ClearEventHashTable() { GetEventHashTable().Clear(); }
|
void ClearEventHashTable() { GetEventHashTable().Clear(); }
|
||||||
|
|
||||||
@@ -2402,18 +2396,9 @@ protected:
|
|||||||
wxList* m_pendingEvents;
|
wxList* m_pendingEvents;
|
||||||
|
|
||||||
#if wxUSE_THREADS
|
#if wxUSE_THREADS
|
||||||
#if defined (__VISAGECPP__)
|
// critical section protecting m_pendingEvents
|
||||||
const wxCriticalSection& Lock() const { return m_eventsLocker; }
|
wxCriticalSection m_pendingEventsLock;
|
||||||
wxCriticalSection& Lock() { return m_eventsLocker; }
|
#endif // wxUSE_THREADS
|
||||||
|
|
||||||
wxCriticalSection m_eventsLocker;
|
|
||||||
# else
|
|
||||||
const wxCriticalSection& Lock() const { return *m_eventsLocker; }
|
|
||||||
wxCriticalSection& Lock() { return *m_eventsLocker; }
|
|
||||||
|
|
||||||
wxCriticalSection* m_eventsLocker;
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Is event handler enabled?
|
// Is event handler enabled?
|
||||||
bool m_enabled;
|
bool m_enabled;
|
||||||
|
@@ -138,13 +138,6 @@ void wxAppBase::CleanUp()
|
|||||||
delete wxTheColourDatabase;
|
delete wxTheColourDatabase;
|
||||||
wxTheColourDatabase = NULL;
|
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();
|
wxAppConsole::CleanUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1028,11 +1028,6 @@ wxEvtHandler::wxEvtHandler()
|
|||||||
m_enabled = true;
|
m_enabled = true;
|
||||||
m_dynamicEvents = (wxList *) NULL;
|
m_dynamicEvents = (wxList *) NULL;
|
||||||
m_pendingEvents = (wxList *) NULL;
|
m_pendingEvents = (wxList *) NULL;
|
||||||
#if wxUSE_THREADS
|
|
||||||
# if !defined(__VISAGECPP__)
|
|
||||||
m_eventsLocker = new wxCriticalSection;
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// no client data (yet)
|
// no client data (yet)
|
||||||
m_clientData = NULL;
|
m_clientData = NULL;
|
||||||
@@ -1068,10 +1063,6 @@ wxEvtHandler::~wxEvtHandler()
|
|||||||
m_pendingEvents->DeleteContents(true);
|
m_pendingEvents->DeleteContents(true);
|
||||||
delete m_pendingEvents;
|
delete m_pendingEvents;
|
||||||
|
|
||||||
# if !defined(__VISAGECPP__)
|
|
||||||
delete m_eventsLocker;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
// Remove us from wxPendingEvents if necessary.
|
// Remove us from wxPendingEvents if necessary.
|
||||||
if ( wxPendingEvents )
|
if ( wxPendingEvents )
|
||||||
{
|
{
|
||||||
@@ -1108,14 +1099,6 @@ bool wxEvtHandler::ProcessThreadEvent(const wxEvent& event)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxEvtHandler::ClearEventLocker()
|
|
||||||
{
|
|
||||||
#if !defined(__VISAGECPP__)
|
|
||||||
delete m_eventsLocker;
|
|
||||||
m_eventsLocker = NULL;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // wxUSE_THREADS
|
#endif // wxUSE_THREADS
|
||||||
|
|
||||||
void wxEvtHandler::AddPendingEvent(const wxEvent& event)
|
void wxEvtHandler::AddPendingEvent(const wxEvent& event)
|
||||||
@@ -1129,14 +1112,14 @@ void wxEvtHandler::AddPendingEvent(const wxEvent& event)
|
|||||||
wxCHECK_RET( eventCopy,
|
wxCHECK_RET( eventCopy,
|
||||||
_T("events of this type aren't supposed to be posted") );
|
_T("events of this type aren't supposed to be posted") );
|
||||||
|
|
||||||
wxENTER_CRIT_SECT( Lock() );
|
wxENTER_CRIT_SECT( m_pendingEventsLock );
|
||||||
|
|
||||||
if ( !m_pendingEvents )
|
if ( !m_pendingEvents )
|
||||||
m_pendingEvents = new wxList;
|
m_pendingEvents = new wxList;
|
||||||
|
|
||||||
m_pendingEvents->Append(eventCopy);
|
m_pendingEvents->Append(eventCopy);
|
||||||
|
|
||||||
wxLEAVE_CRIT_SECT( Lock() );
|
wxLEAVE_CRIT_SECT( m_pendingEventsLock );
|
||||||
|
|
||||||
// 2) Add this event handler to list of event handlers that
|
// 2) Add this event handler to list of event handlers that
|
||||||
// have pending events.
|
// have pending events.
|
||||||
@@ -1157,7 +1140,7 @@ void wxEvtHandler::AddPendingEvent(const wxEvent& event)
|
|||||||
|
|
||||||
void wxEvtHandler::ProcessPendingEvents()
|
void wxEvtHandler::ProcessPendingEvents()
|
||||||
{
|
{
|
||||||
wxENTER_CRIT_SECT( Lock() );
|
wxENTER_CRIT_SECT( m_pendingEventsLock );
|
||||||
|
|
||||||
// this method is only called by wxApp if this handler does have
|
// this method is only called by wxApp if this handler does have
|
||||||
// pending events
|
// pending events
|
||||||
@@ -1177,7 +1160,7 @@ void wxEvtHandler::ProcessPendingEvents()
|
|||||||
if ( m_pendingEvents->IsEmpty() )
|
if ( m_pendingEvents->IsEmpty() )
|
||||||
wxPendingEvents->DeleteObject(this);
|
wxPendingEvents->DeleteObject(this);
|
||||||
|
|
||||||
wxLEAVE_CRIT_SECT( Lock() );
|
wxLEAVE_CRIT_SECT( m_pendingEventsLock );
|
||||||
|
|
||||||
ProcessEvent(*event);
|
ProcessEvent(*event);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user