- // this method is only called by wxApp if this handler does have
- // pending events
- wxCHECK_RET( m_pendingEvents && !m_pendingEvents->IsEmpty(),
- "should have pending events if called" );
+ // This method is only called by wxApp if this handler does have
+ // pending events, but it happens occasionally when using multi-
+ // threading and we don't want a crash due to that.
+ if( !m_pendingEvents )
+ {
+ wxLEAVE_CRIT_SECT( m_pendingEventsLock );
+ return;
+ }
+
+ if( m_pendingEvents->IsEmpty() )
+ {
+ wxPendingEvents->DeleteObject(this);
+ wxLEAVE_CRIT_SECT( m_pendingEventsLock );
+ return;
+ }