Support delayed destruction in console applications too.\n\nThis only works if there is a running event loop but if there is one, we can have the same kind of problems with non-GUI objects such as sockets in console applications as we have with windows in GUI ones, so we must support this (see #10989).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61488 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-07-21 14:16:44 +00:00
parent 2388960a08
commit 3185abc278
8 changed files with 203 additions and 129 deletions

View File

@@ -50,8 +50,6 @@
#include "wx/build.h"
WX_CHECK_BUILD_OPTIONS("wxCore")
WXDLLIMPEXP_DATA_CORE(wxList) wxPendingDelete;
// ============================================================================
// wxAppBase implementation
// ============================================================================
@@ -341,33 +339,11 @@ bool wxAppBase::SafeYieldFor(wxWindow *win, long eventsToProcess)
// idle handling
// ----------------------------------------------------------------------------
void wxAppBase::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();
}
}
// Returns true if more time is needed.
bool wxAppBase::ProcessIdle()
{
// call the base class version first, it will process the pending events
// (which should be done before the idle events generation) and send the
// idle event to wxTheApp itself
// call the base class version first to send the idle event to wxTheApp
// itself
bool needMore = wxAppConsoleBase::ProcessIdle();
wxIdleEvent event;
wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst();
@@ -379,9 +355,6 @@ bool wxAppBase::ProcessIdle()
node = node->GetNext();
}
// 'Garbage' collection of windows deleted with Close().
DeletePendingObjects();
#if wxUSE_LOG
// flush the logged messages if any
wxLog::FlushActive();
@@ -544,14 +517,3 @@ bool wxGUIAppTraitsBase::HasStderr()
#endif
}
void wxGUIAppTraitsBase::ScheduleForDestroy(wxObject *object)
{
if ( !wxPendingDelete.Member(object) )
wxPendingDelete.Append(object);
}
void wxGUIAppTraitsBase::RemoveFromPendingDelete(wxObject *object)
{
wxPendingDelete.DeleteObject(object);
}