From: James Turner Date: Sat, 19 Dec 2015 04:13:23 +0000 (-0800) Subject: Aircraft-model subsystem behaves better X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0f590280c7712afc5e59d186dda83badc07059e8;p=flightgear.git Aircraft-model subsystem behaves better - make shutdown logic more robust - shutdown is no longer special cased in globals. --- diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 012f14371..b5c30e6d6 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -894,7 +894,7 @@ void fgCreateSubsystems(bool duringReset) { globals->add_subsystem("events", globals->get_event_mgr(), SGSubsystemMgr::DISPLAY); } - globals->add_subsystem("aircraft-model", new FGAircraftModel, SGSubsystemMgr::DISPLAY); + globals->add_new_subsystem(SGSubsystemMgr::DISPLAY); globals->add_new_subsystem(SGSubsystemMgr::DISPLAY); globals->add_new_subsystem(SGSubsystemMgr::DISPLAY); diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index 7e22bcfd3..e3f7cbcf3 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -215,8 +215,6 @@ FGGlobals::~FGGlobals() subsystem_mgr->shutdown(); subsystem_mgr->unbind(); - subsystem_mgr->remove("aircraft-model"); - subsystem_mgr->remove(FGTileMgr::subsystemName()); osg::ref_ptr vw(renderer->getViewer()); diff --git a/src/Model/acmodel.cxx b/src/Model/acmodel.cxx index 782145ebe..37ef66fd0 100644 --- a/src/Model/acmodel.cxx +++ b/src/Model/acmodel.cxx @@ -139,17 +139,20 @@ FGAircraftModel::reinit() void FGAircraftModel::shutdown() { - if (!_aircraft.get()) { - return; - } - - osg::Node* node = _aircraft->getSceneGraph(); - globals->get_scenery()->get_aircraft_branch()->removeChild(node); + FGScenery* scenery = globals->get_scenery(); + + if (_aircraft.get()) { + if (scenery && scenery->get_aircraft_branch()) { + scenery->get_aircraft_branch()->removeChild(_aircraft->getSceneGraph()); + } + } if (_interior.get()) { - globals->get_scenery()->get_interior_branch()->removeChild(_interior->getSceneGraph()); + if (scenery && scenery->get_interior_branch()) { + scenery->get_interior_branch()->removeChild(_interior->getSceneGraph()); + } } - + _aircraft.reset(); _interior.reset(); } diff --git a/src/Model/acmodel.hxx b/src/Model/acmodel.hxx index edaaad77c..ec2a9b5af 100644 --- a/src/Model/acmodel.hxx +++ b/src/Model/acmodel.hxx @@ -34,6 +34,7 @@ public: virtual SGModelPlacement * get3DModel() { return _aircraft.get(); } virtual SGVec3d& getVelocity() { return _velocity; } + static const char* subsystemName() { return "aircraft-model"; } private: void deinit ();