X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMain%2Fglobals.cxx;h=084d77128ae73cb6b86f92532c36b34c67f7e5fe;hb=83ea6d32d0504f5a9bd4730ea35275cfc1954392;hp=f0ce2354ee8f5268a4d7bedebb093093ea4deb4d;hpb=2314ccfe13e5e175763000e4c8ba86be79aa3a97;p=flightgear.git diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index f0ce2354e..084d77128 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -50,7 +50,6 @@ #include #include #include -#include #include #include #include @@ -159,9 +158,6 @@ FGGlobals::FGGlobals() : fg_home( "" ), time_params( NULL ), ephem( NULL ), - route_mgr( NULL ), - controls( NULL ), - viewmgr( NULL ), commands( SGCommandMgr::instance() ), channel_options_list( NULL ), initial_waypoints( NULL ), @@ -203,6 +199,19 @@ FGGlobals::~FGGlobals() // save user settings (unless already saved) saveUserSettings(); + // stop OSG threading first, to avoid thread races while we tear down + // scene-graph pieces + + osg::ref_ptr vw(renderer->getViewer()); + if (vw) { + // https://code.google.com/p/flightgear-bugs/issues/detail?id=1291 + // explicitly stop trheading before we delete the renderer or + // viewMgr (which ultimately holds refs to the CameraGroup, and + // GraphicsContext) + vw->stopThreading(); + } + +#if 0 // The AIModels manager performs a number of actions upon // Shutdown that implicitly assume that other subsystems // are still operational (Due to the dynamic allocation and @@ -215,24 +224,12 @@ FGGlobals::~FGGlobals() ai->unbind(); ai.clear(); // ensure AI is deleted now, not at end of this method } +#endif subsystem_mgr->shutdown(); subsystem_mgr->unbind(); - subsystem_mgr->remove("aircraft-model"); - subsystem_mgr->remove("tile-manager"); - subsystem_mgr->remove("model-manager"); - _tile_mgr.clear(); - - osg::ref_ptr vw(renderer->getViewer()); - if (vw) { - // https://code.google.com/p/flightgear-bugs/issues/detail?id=1291 - // explicitly stop trheading before we delete the renderer or - // viewMgr (which ultimately holds refs to the CameraGroup, and - // GraphicsContext) - vw->stopThreading(); - } - + subsystem_mgr->remove(FGTileMgr::subsystemName()); // don't cancel the pager until after shutdown, since AIModels (and // potentially others) can queue delete requests on the pager. if (vw && vw->getDatabasePager()) { @@ -241,10 +238,10 @@ FGGlobals::~FGGlobals() } osgDB::Registry::instance()->clearObjectCache(); + subsystem_mgr->remove(FGScenery::subsystemName()); // renderer touches subsystems during its destruction set_renderer(NULL); - _scenery.clear(); _chatter_queue.clear(); delete subsystem_mgr; @@ -253,7 +250,7 @@ FGGlobals::~FGGlobals() delete time_params; set_matlib(NULL); - delete route_mgr; + delete channel_options_list; delete initial_waypoints; delete fontcache; @@ -354,7 +351,7 @@ SGPath FGGlobals::find_data_dir(const std::string& pathSuffix) const return SGPath(); } -void FGGlobals::append_fg_scenery (const std::string &paths) +void FGGlobals::append_fg_scenery (const std::string &paths, bool secure) { SGPropertyNode* sim = fgGetNode("/sim", true); @@ -387,6 +384,9 @@ void FGGlobals::append_fg_scenery (const std::string &paths) // out, such that all three dirs are added. Unfortunately there's // no information as to why the change was made. fg_scenery.push_back(abspath.str()); + if (secure) { + secure_fg_scenery.push_back(abspath.str()); + } if (terrainDir.exists()) { fg_scenery.push_back(terrainDir.str()); @@ -414,6 +414,9 @@ void FGGlobals::append_fg_scenery (const std::string &paths) void FGGlobals::clear_fg_scenery() { fg_scenery.clear(); + secure_fg_scenery.clear(); + fgGetNode("/sim", true)->removeChildren("fg-scenery"); + } void FGGlobals::set_catalog_aircraft_path(const SGPath& path) @@ -503,7 +506,7 @@ FGGlobals::get_subsystem_mgr () const } SGSubsystem * -FGGlobals::get_subsystem (const char * name) +FGGlobals::get_subsystem (const char * name) const { if (!subsystem_mgr) { return NULL; @@ -524,10 +527,7 @@ FGGlobals::add_subsystem (const char * name, SGSoundMgr * FGGlobals::get_soundmgr () const { - if (subsystem_mgr) - return (SGSoundMgr*) subsystem_mgr->get_subsystem("sound"); - - return NULL; + return get_subsystem(); } SGEventMgr * @@ -694,12 +694,6 @@ FGGlobals::saveUserSettings() } } -FGViewer * -FGGlobals::get_current_view () const -{ - return viewmgr->get_current_view(); -} - long int FGGlobals::get_warp() const { return fgGetInt("/sim/time/warp"); @@ -722,22 +716,23 @@ void FGGlobals::set_warp_delta( long int d ) FGScenery* FGGlobals::get_scenery () const { - return _scenery.get(); + return get_subsystem(); } -void FGGlobals::set_scenery ( FGScenery *s ) +FGTileMgr* FGGlobals::get_tile_mgr () const { - _scenery = s; + return get_subsystem(); } -FGTileMgr* FGGlobals::get_tile_mgr () const +FGViewMgr *FGGlobals::get_viewmgr() const { - return _tile_mgr.get(); + return get_subsystem(); } -void FGGlobals::set_tile_mgr ( FGTileMgr *t ) +FGViewer* FGGlobals::get_current_view () const { - _tile_mgr = t; + FGViewMgr* vm = get_viewmgr(); + return vm ? vm->get_current_view() : 0; } void FGGlobals::set_matlib( SGMaterialLib *m ) @@ -745,6 +740,11 @@ void FGGlobals::set_matlib( SGMaterialLib *m ) matlib = m; } +FGControls *FGGlobals::get_controls() const +{ + return get_subsystem(); +} + FGSampleQueue* FGGlobals::get_chatter_queue() const { return _chatter_queue;