From 35a0ba4fcee1539817e096ee2b3f11d8a844f1df Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 17 Jan 2018 11:32:07 +0100 Subject: [PATCH] Avoid crash on abnormal exit in wx+MFC combined applications Reset m_pMainWnd in wxMFCApp::ExitInstance() to avoid crash when deleting it again in OnMainWindowDestroyed() that could happen if ExitInstance() was called not because the main window was closed (normal case) but because wxApp::ExitMainLoop() was called, as it happens when an unhandled exception is thrown. --- include/wx/msw/mfc.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/wx/msw/mfc.h b/include/wx/msw/mfc.h index 8cab2ee37f..830db351ac 100644 --- a/include/wx/msw/mfc.h +++ b/include/wx/msw/mfc.h @@ -81,6 +81,7 @@ public: int ExitInstance() wxOVERRIDE { delete m_pMainWnd; + m_pMainWnd = NULL; if ( wxTheApp ) wxTheApp->OnExit();