Fix possible deadlock in wxEvtHandler::ProcessPendingEvents().

Delete the event we just processed before re-locking the critical section as
this may result in deadlocks if the (user-defined) event dtor does something
non-trivial.

Closes #10790.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@61982 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-09-20 21:48:50 +00:00
parent c78e95f633
commit f15c021bb6

View File

@@ -1182,17 +1182,21 @@ void wxEvtHandler::ProcessPendingEvents()
node; node;
node = m_pendingEvents->GetFirst() ) node = m_pendingEvents->GetFirst() )
{ {
wxEventPtr event(wx_static_cast(wxEvent *, node->GetData())); {
wxEventPtr event(wx_static_cast(wxEvent *, node->GetData()));
// It's important we remove event from list before processing it. // It's important we remove event from list before processing it.
// Else a nested event loop, for example from a modal dialog, might // Else a nested event loop, for example from a modal dialog, might
// process the same event again. // process the same event again.
m_pendingEvents->Erase(node); m_pendingEvents->Erase(node);
wxLEAVE_CRIT_SECT( Lock() ); wxLEAVE_CRIT_SECT( Lock() );
ProcessEvent(*event); ProcessEvent(*event);
} // delete the event at this block exit, before re-locking our
// critical section, to avoid deadlocks if the event dtor locks
// something else itself (see #10790)
wxENTER_CRIT_SECT( Lock() ); wxENTER_CRIT_SECT( Lock() );