+// A helper func to find an wxEventConnectionRef object
+wxEventConnectionRef* wxEvtHandler::FindRefInTrackerList( wxEvtHandler *eventSink )
+{
+ wxASSERT(eventSink);
+ for( wxTrackerNode *ptn=eventSink->GetFirst(); ptn; ptn=ptn->m_nxt )
+ {
+ // Only want wxEventConnectionRef nodes here
+ if( ptn->GetType()!=wxTrackerNode::EventConnectionRef )
+ continue;
+ wxEventConnectionRef *pecr = static_cast<wxEventConnectionRef*>(ptn);
+ if( pecr && pecr->m_src==this )
+ {
+ wxASSERT( pecr->m_sink==eventSink );
+ return pecr;
+ }
+ }
+ return NULL;
+}
+
+void wxEvtHandler::OnSinkDestroyed( wxEvtHandler *sink )
+{
+ wxASSERT(m_dynamicEvents);
+
+ // remove all connections with this sink
+ wxList::compatibility_iterator node = m_dynamicEvents->GetFirst(), node_nxt;
+ while (node)
+ {
+ wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)node->GetData();
+ node_nxt = node->GetNext();
+
+ if( entry->m_eventSink==sink )
+ {
+ if (entry->m_callbackUserData)
+ delete entry->m_callbackUserData;
+ m_dynamicEvents->Erase( node );
+ delete entry;
+ }
+ node = node_nxt;
+ }
+}
+