don't compare iterator after calling erase() in ProcessPendingEvents() (replaces patch 1153906)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32507 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1123,30 +1123,28 @@ void wxEvtHandler::ProcessPendingEvents()
|
|||||||
|
|
||||||
wxENTER_CRIT_SECT( Lock() );
|
wxENTER_CRIT_SECT( Lock() );
|
||||||
|
|
||||||
// remember last event to process during this iteration
|
// we leave the loop once we have processed all events that were present at
|
||||||
wxList::compatibility_iterator lastPendingNode = m_pendingEvents->GetLast();
|
// the start of ProcessPendingEvents because otherwise we could get into
|
||||||
|
// infinite loop if the pending event handler execution resulted in another
|
||||||
wxList::compatibility_iterator node = m_pendingEvents->GetFirst();
|
// event being posted
|
||||||
while ( node )
|
size_t n = m_pendingEvents->size();
|
||||||
|
for ( wxList::compatibility_iterator node = m_pendingEvents->GetFirst();
|
||||||
|
node;
|
||||||
|
node = m_pendingEvents->GetFirst() )
|
||||||
{
|
{
|
||||||
wxEvent *event = (wxEvent *)node->GetData();
|
wxEvent *event = (wxEvent *)node->GetData();
|
||||||
|
|
||||||
m_pendingEvents->Erase(node);
|
m_pendingEvents->Erase(node);
|
||||||
|
|
||||||
// In ProcessEvent, new events might get added and
|
|
||||||
// we can safely leave the crtical section here.
|
|
||||||
wxLEAVE_CRIT_SECT( Lock() );
|
wxLEAVE_CRIT_SECT( Lock() );
|
||||||
|
|
||||||
ProcessEvent(*event);
|
ProcessEvent(*event);
|
||||||
delete event;
|
delete event;
|
||||||
|
|
||||||
wxENTER_CRIT_SECT( Lock() );
|
wxENTER_CRIT_SECT( Lock() );
|
||||||
|
|
||||||
// leave the loop once we have processed all events that were present
|
if ( !--n )
|
||||||
// at the start of ProcessPendingEvents because otherwise we could get
|
|
||||||
// into infinite loop if the pending event handler execution resulted
|
|
||||||
// in another event being posted
|
|
||||||
if ( node == lastPendingNode )
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
node = m_pendingEvents->GetFirst();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxLEAVE_CRIT_SECT( Lock() );
|
wxLEAVE_CRIT_SECT( Lock() );
|
||||||
|
Reference in New Issue
Block a user