- // Remove us from wxHandlersWithPendingEvents if necessary.
- if ( wxHandlersWithPendingEvents )
- {
-#if wxUSE_THREADS
- if (wxHandlersWithPendingEventsLocker)
- wxENTER_CRIT_SECT(*wxHandlersWithPendingEventsLocker);
-#endif
-
- if ( wxHandlersWithPendingEvents->DeleteObject(this) )
- {
- // check that we were present only once in the list
- wxASSERT_MSG( !wxHandlersWithPendingEvents->Find(this),
- "Handler occurs twice in wxHandlersWithPendingEvents list" );
- }
- //else: we weren't in this list at all, it's ok
-
- if ( wxHandlersWithPendingDelayedEvents->DeleteObject(this) )
- {
- // check that we were present only once in the list
- wxASSERT_MSG( !wxHandlersWithPendingDelayedEvents->Find(this),
- "Handler occurs twice in wxHandlersWithPendingDelayedEvents list" );
- }
- //else: we weren't in this list at all, it's ok
-
-#if wxUSE_THREADS
- if (wxHandlersWithPendingEventsLocker)
- wxLEAVE_CRIT_SECT(*wxHandlersWithPendingEventsLocker);
-#endif
- }
+ // Remove us from the list of the pending events if necessary.
+ wxEventLoopBase *loop = wxEventLoopBase::GetActive();
+ if (loop)
+ loop->RemovePendingEventHandler(this);