]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix crasher caused by wxProcessTerminationEventHandler::OnTerminate killing
authorDavid Elliott <dfe@tgwbd.org>
Thu, 18 Oct 2007 09:31:21 +0000 (09:31 +0000)
committerDavid Elliott <dfe@tgwbd.org>
Thu, 18 Oct 2007 09:31:21 +0000 (09:31 +0000)
itself inside the context of wxEvtHandler::ProcessPendingEvents which
still needs itself to be valid because it accesses it's m_eventsLocker.

NOTE: This code is no longer used on trunk and hopefully soon won't be
used in 2.8 either, but at least it doesn't crash now.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49219 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/mac/corefoundation/utilsexc_cf.cpp

index d32a8c8a5aaa5b1cf177ea151c42bbc1209f39b3..85b374efd0db4eb99fc787ba42290f09b72b08ad 100644 (file)
@@ -17,6 +17,7 @@
 #endif //ndef WX_PRECOMP
 #include "wx/unix/execute.h"
 #include "wx/stdpaths.h"
+#include "wx/app.h"
 #include "wx/apptrait.h"
 #include "wx/thread.h"
 #include "wx/process.h"
@@ -51,7 +52,14 @@ class wxProcessTerminationEventHandler: public wxEvtHandler
     {
         Disconnect(-1, wxEVT_END_PROCESS, wxProcessEventHandler(wxProcessTerminationEventHandler::OnTerminate));
         wxHandleProcessTermination(m_data);
-        delete this;
+
+        // NOTE: We don't use this to delay destruction until the next idle run but rather to
+        // avoid killing ourselves while our caller (which is our wxEvtHandler superclass
+        // ProcessPendingEvents) still needs our m_eventsLocker to be valid.
+        // Since we're in the GUI library we can guarantee that ScheduleForDestroy is using
+        // the GUI implementation which delays destruction and not the base implementation
+        // which does it immediately.
+        wxTheApp->GetTraits()->ScheduleForDestroy(this);
     }
 
     wxEndProcessData* m_data;