]> git.mxchange.org Git - flightgear.git/commitdiff
Reset, fix Nasal timers added on shutdown.
authorJames Turner <zakalawe@mac.com>
Mon, 13 Jan 2014 16:41:31 +0000 (16:41 +0000)
committerJames Turner <zakalawe@mac.com>
Mon, 13 Jan 2014 20:13:34 +0000 (20:13 +0000)
src/AIModel/AIManager.cxx
src/Main/fg_init.cxx
src/Main/globals.cxx

index c0d8a78a7fe24ce757f34ae9ac3427a21bbf83a1..aa80b26c5d032a600bca8b10b0e83d56f9fcc79d 100644 (file)
@@ -85,6 +85,9 @@ public:
         }
         
         FGNasalSys* nasalSys = (FGNasalSys*) globals->get_subsystem("nasal");
+        if (!nasalSys)
+            return;
+        
         std::string moduleName = "scenario_" + _internalName;
         if (!_unloadScript.empty()) {
             nasalSys->createModule(moduleName.c_str(), moduleName.c_str(),
index cdba3a14483ac2dc1e2823b6f0255896eadf141d..3abb334601472843151010de39fdc7721254706f 100644 (file)
@@ -948,6 +948,13 @@ void fgStartNewReset()
     fgSetBool("/sim/freeze/master", true);
     
     SGSubsystemMgr* subsystemManger = globals->get_subsystem_mgr();
+    // Nasal is manually inited in fgPostInit, ensure it's already shutdown
+    // before other subsystems, so Nasal listeners don't fire during shutdonw
+    SGSubsystem* nasal = subsystemManger->get_subsystem("nasal");
+    nasal->shutdown();
+    nasal->unbind();
+    subsystemManger->remove("nasal");
+    
     subsystemManger->shutdown();
     subsystemManger->unbind();
     
index f1f8bd1e592f668e89e1234bcc42224fa31e4e0b..3f469d05a2df3476a6888345bd555287750fd258 100644 (file)
@@ -544,6 +544,18 @@ static void treeDumpRefCounts(int depth, SGPropertyNode* nd)
     }
 }
 
+static void treeClearAliases(SGPropertyNode* nd)
+{
+    if (nd->isAlias()) {
+        nd->unalias();
+    }
+    
+    for (int i=0; i<nd->nChildren(); ++i) {
+        SGPropertyNode* cp = nd->getChild(i);
+        treeClearAliases(cp);
+    }
+}
+
 void
 FGGlobals::resetPropertyRoot()
 {
@@ -564,6 +576,9 @@ FGGlobals::resetPropertyRoot()
     orientHeading.clear();
     orientRoll.clear();
     
+    // clear aliases so ref-counts are accurate when dumped
+    treeClearAliases(props);
+    
     SG_LOG(SG_GENERAL, SG_INFO, "root props refcount:" << props.getNumRefs());
     treeDumpRefCounts(0, props);