]> git.mxchange.org Git - flightgear.git/commitdiff
Replace a program segmentation fault by an annoying message
authorErik Hofman <erik@ehofman.com>
Mon, 14 Dec 2015 10:14:40 +0000 (11:14 +0100)
committerErik Hofman <erik@ehofman.com>
Mon, 14 Dec 2015 10:14:40 +0000 (11:14 +0100)
src/Model/modelmgr.cxx

index 46ed240f4c8d2f17c7e3d17a4e099bc8d484ad0c..a92a5d5eee87b8c3284b025543d9fa0443e2e9da 100644 (file)
@@ -42,14 +42,19 @@ FGModelMgr::FGModelMgr ()
   _models->addChangeListener(_listener);
 }
 
+#include <stdio.h>
 FGModelMgr::~FGModelMgr ()
 {
   _models->removeChangeListener(_listener);
   delete _listener;
 
+  osg::Group *scene_graph = globals->get_scenery()->get_scene_graph();
+  if (!scene_graph)
+    SG_LOG(SG_AIRCRAFT, SG_ALERT, "Warning: The scenegraph wass deleted before the models could be removed");
+
   for (unsigned int i = 0; i < _instances.size(); i++) {
-    globals->get_scenery()->get_scene_graph()
-      ->removeChild(_instances[i]->model->getSceneGraph());
+    if (scene_graph)
+      scene_graph->removeChild(_instances[i]->model->getSceneGraph());
     delete _instances[i];
   }
 }