From 061154d7a695f62ab7b0ccba5308f634c5285011 Mon Sep 17 00:00:00 2001 From: James Turner Date: Mon, 13 Jan 2014 16:41:31 +0000 Subject: [PATCH] Reset, fix Nasal timers added on shutdown. --- src/AIModel/AIManager.cxx | 3 +++ src/Main/fg_init.cxx | 7 +++++++ src/Main/globals.cxx | 15 +++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx index c0d8a78a7..aa80b26c5 100644 --- a/src/AIModel/AIManager.cxx +++ b/src/AIModel/AIManager.cxx @@ -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(), diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index cdba3a144..3abb33460 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -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(); diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index f1f8bd1e5..3f469d05a 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -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; inChildren(); ++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); -- 2.39.5