- // DE: It doesn't look like this method was intended to be called unless
- // pending events have already been created.
- wxASSERT_MSG(m_pendingEvents,wxT("Please call wxApp::ProcessPendingEvents() instead"));
-#if defined(__VISAGECPP__)
- wxENTER_CRIT_SECT( m_eventsLocker);
-#else
- wxENTER_CRIT_SECT( *m_eventsLocker);
-#endif
-
- wxList::compatibility_iterator node = m_pendingEvents->GetFirst();
- while ( node )
+ // this method is only called by wxApp if this handler does have
+ // pending events
+ wxCHECK_RET( m_pendingEvents,
+ wxT("Please call wxApp::ProcessPendingEvents() instead") );
+
+ // eventhandling is now in progess
+ m_eventHandlingInProgress = true;
+
+ wxENTER_CRIT_SECT( Lock() );
+
+ // we leave the loop once we have processed all events that were present 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
+ size_t n = m_pendingEvents->size();
+ for ( wxList::compatibility_iterator node = m_pendingEvents->GetFirst();
+ node;
+ node = m_pendingEvents->GetFirst() )