]> git.mxchange.org Git - flightgear.git/commitdiff
Aircraft-model subsystem behaves better
authorJames Turner <zakalawe@mac.com>
Sat, 19 Dec 2015 04:13:23 +0000 (20:13 -0800)
committerJames Turner <zakalawe@mac.com>
Sat, 19 Dec 2015 04:13:23 +0000 (20:13 -0800)
- make shutdown logic more robust
- shutdown is no longer special cased in globals.

src/Main/fg_init.cxx
src/Main/globals.cxx
src/Model/acmodel.cxx
src/Model/acmodel.hxx

index 012f1437123e30eb452ac18220a9ffdf5f44d8cc..b5c30e6d663e42eb8b4d351d9fcc909470929093 100644 (file)
@@ -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<FGAircraftModel>(SGSubsystemMgr::DISPLAY);
     globals->add_new_subsystem<FGModelMgr>(SGSubsystemMgr::DISPLAY);
 
     globals->add_new_subsystem<FGViewMgr>(SGSubsystemMgr::DISPLAY);
index 7e22bcfd34bfaaae3440a02ef20a704b3fbab83c..e3f7cbcf37ced137afac91dc7425f6e1ca4456b7 100644 (file)
@@ -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<osgViewer::Viewer> vw(renderer->getViewer());
index 782145ebec4d546cdc6c5ba02c2bffff74a51b04..37ef66fd08e8f5c5d91eeb6149df201d95edcb99 100644 (file)
@@ -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();
 }
index edaaad77cbda801aa658aa43ac96a959fbafadb4..ec2a9b5afda509d28a284cfe0f20145bb6e87dc1 100644 (file)
@@ -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 ();