From: Erik Hofman Date: Mon, 14 Dec 2015 10:14:40 +0000 (+0100) Subject: Replace a program segmentation fault by an annoying message X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a5e516fe8cc5775aebfe8afa0328e6f26824d1bd;p=flightgear.git Replace a program segmentation fault by an annoying message --- diff --git a/src/Model/modelmgr.cxx b/src/Model/modelmgr.cxx index 46ed240f4..a92a5d5ee 100644 --- a/src/Model/modelmgr.cxx +++ b/src/Model/modelmgr.cxx @@ -42,14 +42,19 @@ FGModelMgr::FGModelMgr () _models->addChangeListener(_listener); } +#include 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]; } }