From bfb8eb7eaef3576df054d66255165eb53eaea660 Mon Sep 17 00:00:00 2001 From: Michael Wetherell Date: Sat, 30 Jul 2005 23:15:52 +0000 Subject: [PATCH] Defer deletion of wxFontsManager and MGL_exit until after the modules have been cleaned up git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35032 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mgl/app.cpp | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/mgl/app.cpp b/src/mgl/app.cpp index 62207edf46..f8b7d3794a 100644 --- a/src/mgl/app.cpp +++ b/src/mgl/app.cpp @@ -21,7 +21,6 @@ #ifndef WX_PRECOMP #include "wx/settings.h" - #include "wx/module.h" #include "wx/frame.h" #include "wx/dialog.h" #include "wx/log.h" @@ -30,6 +29,7 @@ #include "wx/app.h" #include "wx/evtloop.h" +#include "wx/module.h" #include "wx/fontutil.h" #include "wx/univ/theme.h" #include "wx/univ/renderer.h" @@ -306,17 +306,31 @@ bool wxApp::Initialize(int& argc, wxChar **argv) return true; } +// Modules are cleaned up after wxApp::CleanUp(), and some modules may +// require MGL to still be alive, e.g. the stock fonts need the fonts +// manager. So append this module last minute in wxApp::CleanUp() to close +// down MGL after all the other modules have been cleaned up. +// +struct wxMGLFinalCleanup: public wxModule +{ + bool OnInit() { return true; } + + void OnExit() + { + delete wxTheFontsManager; + wxTheFontsManager = (wxFontsManager*) NULL; + + wxDestroyMGL_WM(); + MGL_exit(); + } +}; + void wxApp::CleanUp() { delete gs_rootWindow; wxAppBase::CleanUp(); - // must do this after calling base class CleanUp() - delete wxTheFontsManager; - wxTheFontsManager = (wxFontsManager*) NULL; - - wxDestroyMGL_WM(); - MGL_exit(); + wxModule::RegisterModule(new wxMGLFinalCleanup); }