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:
parent
ad294cb8f6
commit
8ebec7dcd8
@ -23,15 +23,13 @@
|
||||
#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;
|
||||
@ -2359,10 +2357,6 @@ public:
|
||||
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(); }
|
||||
|
||||
@ -2402,18 +2396,9 @@ protected:
|
||||
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;
|
||||
|
@ -138,13 +138,6 @@ void wxAppBase::CleanUp()
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -1028,11 +1028,6 @@ wxEvtHandler::wxEvtHandler()
|
||||
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;
|
||||
@ -1068,10 +1063,6 @@ wxEvtHandler::~wxEvtHandler()
|
||||
m_pendingEvents->DeleteContents(true);
|
||||
delete m_pendingEvents;
|
||||
|
||||
# if !defined(__VISAGECPP__)
|
||||
delete m_eventsLocker;
|
||||
# endif
|
||||
|
||||
// Remove us from wxPendingEvents if necessary.
|
||||
if ( wxPendingEvents )
|
||||
{
|
||||
@ -1108,14 +1099,6 @@ bool wxEvtHandler::ProcessThreadEvent(const wxEvent& event)
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxEvtHandler::ClearEventLocker()
|
||||
{
|
||||
#if !defined(__VISAGECPP__)
|
||||
delete m_eventsLocker;
|
||||
m_eventsLocker = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // wxUSE_THREADS
|
||||
|
||||
void wxEvtHandler::AddPendingEvent(const wxEvent& event)
|
||||
@ -1129,14 +1112,14 @@ 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.
|
||||
@ -1157,7 +1140,7 @@ void wxEvtHandler::AddPendingEvent(const wxEvent& event)
|
||||
|
||||
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
|
||||
@ -1177,7 +1160,7 @@ void wxEvtHandler::ProcessPendingEvents()
|
||||
if ( m_pendingEvents->IsEmpty() )
|
||||
wxPendingEvents->DeleteObject(this);
|
||||
|
||||
wxLEAVE_CRIT_SECT( Lock() );
|
||||
wxLEAVE_CRIT_SECT( m_pendingEventsLock );
|
||||
|
||||
ProcessEvent(*event);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user