+// ----------------------------------------------------------------------------
+// delayed objects destruction
+// ----------------------------------------------------------------------------
+
+bool wxAppConsoleBase::IsScheduledForDestruction(wxObject *object) const
+{
+ return wxPendingDelete.Member(object);
+}
+
+void wxAppConsoleBase::ScheduleForDestruction(wxObject *object)
+{
+ if ( !UsesEventLoop() )
+ {
+ // we won't be able to delete it later so do it right now
+ delete object;
+ return;
+ }
+ //else: we either already have or will soon start an event loop
+
+ if ( !wxPendingDelete.Member(object) )
+ wxPendingDelete.Append(object);
+}
+
+void wxAppConsoleBase::DeletePendingObjects()
+{
+ wxList::compatibility_iterator node = wxPendingDelete.GetFirst();
+ while (node)
+ {
+ wxObject *obj = node->GetData();
+
+ // remove it from the list first so that if we get back here somehow
+ // during the object deletion (e.g. wxYield called from its dtor) we
+ // wouldn't try to delete it the second time
+ if ( wxPendingDelete.Member(obj) )
+ wxPendingDelete.Erase(node);
+
+ delete obj;
+
+ // Deleting one object may have deleted other pending
+ // objects, so start from beginning of list again.
+ node = wxPendingDelete.GetFirst();
+ }
+}
+