fixed problems with sometimes processing the events twice introduced in rev 1.170 but still don't leak memory (Tim Kosse)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36330 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1023,6 +1023,8 @@ wxEvtHandler::~wxEvtHandler()
|
|||||||
delete m_dynamicEvents;
|
delete m_dynamicEvents;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (m_pendingEvents)
|
||||||
|
m_pendingEvents->DeleteContents(true);
|
||||||
delete m_pendingEvents;
|
delete m_pendingEvents;
|
||||||
|
|
||||||
#if wxUSE_THREADS
|
#if wxUSE_THREADS
|
||||||
@@ -1084,10 +1086,7 @@ void wxEvtHandler::AddPendingEvent(wxEvent& event)
|
|||||||
wxENTER_CRIT_SECT( Lock() );
|
wxENTER_CRIT_SECT( Lock() );
|
||||||
|
|
||||||
if ( !m_pendingEvents )
|
if ( !m_pendingEvents )
|
||||||
{
|
|
||||||
m_pendingEvents = new wxList;
|
m_pendingEvents = new wxList;
|
||||||
m_pendingEvents->DeleteContents(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_pendingEvents->Append(eventCopy);
|
m_pendingEvents->Append(eventCopy);
|
||||||
|
|
||||||
@@ -1129,14 +1128,18 @@ void wxEvtHandler::ProcessPendingEvents()
|
|||||||
{
|
{
|
||||||
wxEvent *event = (wxEvent *)node->GetData();
|
wxEvent *event = (wxEvent *)node->GetData();
|
||||||
|
|
||||||
|
// It's importan we remove event from list before processing it.
|
||||||
|
// Else a nested event loop, for example from a modal dialog, might
|
||||||
|
// process the same event again.
|
||||||
|
m_pendingEvents->Erase(node);
|
||||||
|
|
||||||
wxLEAVE_CRIT_SECT( Lock() );
|
wxLEAVE_CRIT_SECT( Lock() );
|
||||||
|
|
||||||
ProcessEvent(*event);
|
ProcessEvent(*event);
|
||||||
|
delete event;
|
||||||
|
|
||||||
wxENTER_CRIT_SECT( Lock() );
|
wxENTER_CRIT_SECT( Lock() );
|
||||||
|
|
||||||
m_pendingEvents->Erase(node);
|
|
||||||
|
|
||||||
if ( !--n )
|
if ( !--n )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user