From 73865dad6e17b7e0a969ae9f0b1e5f0ca9e146f9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 25 Aug 2006 15:49:11 +0000 Subject: [PATCH] remove the object from wxPendingDelete list before deleting it to avoid infinite loop if DeletePendingObject() is reentered from object dtor git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40821 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/appcmn.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/common/appcmn.cpp b/src/common/appcmn.cpp index 516a0acf10..4cc829b673 100644 --- a/src/common/appcmn.cpp +++ b/src/common/appcmn.cpp @@ -366,11 +366,14 @@ void wxAppBase::DeletePendingObjects() { wxObject *obj = node->GetData(); - delete obj; - - if (wxPendingDelete.Member(obj)) + // 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();