]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/appcmn.cpp
Fixed ReadLine missing last character from text files with no final newline.
[wxWidgets.git] / src / common / appcmn.cpp
index d78a126972be518ffeffc3d7acf83263eff519c4..4cc829b6738306055afdb0dd78cc9ce4e6760667 100644 (file)
 #endif
 
 #ifndef WX_PRECOMP
+    #include "wx/list.h"
     #include "wx/app.h"
     #include "wx/bitmap.h"
     #include "wx/intl.h"
-    #include "wx/list.h"
     #include "wx/log.h"
     #include "wx/msgdlg.h"
-    #include "wx/bitmap.h"
     #include "wx/confbase.h"
+    #include "wx/utils.h"
 #endif
 
 #include "wx/apptrait.h"
@@ -40,7 +40,6 @@
 #include "wx/evtloop.h"
 #include "wx/msgout.h"
 #include "wx/thread.h"
-#include "wx/utils.h"
 #include "wx/ptr_scpd.h"
 
 #if defined(__WXMSW__)
@@ -55,6 +54,7 @@
 #include "wx/build.h"
 WX_CHECK_BUILD_OPTIONS("wxCore")
 
+WXDLLIMPEXP_DATA_CORE(wxList) wxPendingDelete;
 
 // ----------------------------------------------------------------------------
 // wxEventLoopPtr
@@ -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();