]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/globals.cxx
Make FGIO a proper subsystem and add a reinit method for the generic protocol. This...
[flightgear.git] / src / Main / globals.cxx
index 0b550b46c7144a534057c7d8231252042e017346..262423c2aec68a5fec223e1e11c9e3731882c55f 100644 (file)
@@ -67,6 +67,9 @@ FGGlobals *globals;
 
 // Constructor
 FGGlobals::FGGlobals() :
+    props( new SGPropertyNode ),
+    initial_state( NULL ),
+    locale( NULL ),
     renderer( new FGRenderer ),
     subsystem_mgr( new SGSubsystemMgr ),
     event_mgr( new SGEventMgr ),
@@ -85,9 +88,6 @@ FGGlobals::FGGlobals() :
     AI_mgr( NULL ),
     controls( NULL ),
     viewmgr( NULL ),
-    props( new SGPropertyNode ),
-    initial_state( NULL ),
-    locale( NULL ),
     commands( SGCommandMgr::instance() ),
     acmodel( NULL ),
     model_mgr( NULL ),
@@ -95,7 +95,6 @@ FGGlobals::FGGlobals() :
     initial_waypoints( NULL ),
     scenery( NULL ),
     tile_mgr( NULL ),
-    io( new FGIO ),
     fontcache ( new FGFontCache ),
     navlist( NULL ),
     loclist( NULL ),
@@ -121,6 +120,13 @@ FGGlobals::~FGGlobals()
     // shut down all subsystems, make sure we take down the 
     // AIModels system first.
     subsystem_mgr->get_group(SGSubsystemMgr::GENERAL)->remove_subsystem("ai_model");
+    // FGInput (FGInputEvent) and FGDialog calls get_subsystem() in their destructors, 
+    // which is not safe since some subsystem are already deleted but can be referred.
+    // So these subsystems must be deleted prior to deleting subsystem_mgr unless
+    // ~SGSubsystemGroup and SGSubsystemMgr::get_subsystem are changed not to refer to
+    // deleted subsystems.
+    subsystem_mgr->get_group(SGSubsystemMgr::GENERAL)->remove_subsystem("input");
+    subsystem_mgr->get_group(SGSubsystemMgr::GENERAL)->remove_subsystem("gui");
     delete subsystem_mgr;
     delete event_mgr;
     delete time_params;
@@ -143,7 +149,6 @@ FGGlobals::~FGGlobals()
     delete initial_waypoints;
     delete tile_mgr;
     delete scenery;
-    delete io;
     delete fontcache;
 
     delete navlist;