add wxAppConsoleBase::DeletePendingEvents and wxEvtHandler::DeletePendingEvents.

Fix wxAppConsoleBase::Suspend/ResumeProcessingOfPendingEvents: locking the mutex does not prevent wxAppConsoleBase::ProcessPendingEvents from running if the mutex was locked from the main thread!

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59433 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Francesco Montorsi
2009-03-08 12:58:24 +00:00
parent db034c5228
commit cae9e7b169
6 changed files with 97 additions and 13 deletions

View File

@@ -132,6 +132,7 @@ wxAppConsoleBase::wxAppConsoleBase()
{
m_traits = NULL;
m_mainLoop = NULL;
m_bDoPendingEventProcessing = true;
ms_appInstance = static_cast<wxAppConsole *>(this);
@@ -415,17 +416,19 @@ bool wxAppConsoleBase::HasPendingEvents() const
void wxAppConsoleBase::SuspendProcessingOfPendingEvents()
{
wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker);
// entering the critical section locks blocks calls to ProcessPendingEvents()
m_bDoPendingEventProcessing = false;
}
void wxAppConsoleBase::ResumeProcessingOfPendingEvents()
{
wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker);
m_bDoPendingEventProcessing = true;
}
void wxAppConsoleBase::ProcessPendingEvents()
{
if (!m_bDoPendingEventProcessing)
return;
wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker);
wxCHECK_RET( m_handlersWithPendingDelayedEvents.IsEmpty(),
@@ -462,6 +465,21 @@ void wxAppConsoleBase::ProcessPendingEvents()
wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker);
}
void wxAppConsoleBase::DeletePendingEvents()
{
wxENTER_CRIT_SECT(m_handlersWithPendingEventsLocker);
wxCHECK_RET( m_handlersWithPendingDelayedEvents.IsEmpty(),
"this helper list should be empty" );
for (unsigned int i=0; i<m_handlersWithPendingEvents.GetCount(); i++)
m_handlersWithPendingEvents[i]->DeletePendingEvents();
m_handlersWithPendingEvents.Clear();
wxLEAVE_CRIT_SECT(m_handlersWithPendingEventsLocker);
}
// ----------------------------------------------------------------------------
// exception handling
// ----------------------------------------------------------------------------