X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMain%2Fglobals.cxx;h=796b18cd8f66d1ef35085ca9f8b738efd2534056;hb=6fc24034495c8a9932600e366615d500f1a5a66a;hp=eedfd21bcb8e7587f244d8c97f2565d472452603;hpb=43fcbd22463b32d95678edf920d7184055b2d63e;p=flightgear.git diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index eedfd21bc..796b18cd8 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -48,14 +48,12 @@ #include #include #include -#include #include #include #include #include #include #include -#include #include "globals.hxx" #include "locale.hxx" @@ -157,15 +155,11 @@ FGGlobals::FGGlobals() : fg_root( "" ), fg_home( "" ), time_params( NULL ), - ephem( NULL ), - viewmgr( NULL ), commands( SGCommandMgr::instance() ), channel_options_list( NULL ), initial_waypoints( NULL ), - fontcache ( new FGFontCache ), channellist( NULL ), - haveUserSettings(false), - _chatter_queue(NULL) + haveUserSettings(false) { SGPropertyNode* root = new SGPropertyNode; props = SGPropertyNode_ptr(root); @@ -200,26 +194,8 @@ FGGlobals::~FGGlobals() // save user settings (unless already saved) saveUserSettings(); - // 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 - // deallocation of AIModel objects. To ensure we can safely - // shut down all subsystems, make sure we take down the - // AIModels system first. - SGSubsystemRef ai = subsystem_mgr->get_subsystem("ai-model"); - if (ai) { - subsystem_mgr->remove("ai-model"); - ai->unbind(); - ai.clear(); // ensure AI is deleted now, not at end of this method - } - - subsystem_mgr->shutdown(); - subsystem_mgr->unbind(); - - subsystem_mgr->remove("aircraft-model"); - subsystem_mgr->remove("tile-manager"); - subsystem_mgr->remove("model-manager"); - _tile_mgr.clear(); + // stop OSG threading first, to avoid thread races while we tear down + // scene-graph pieces osg::ref_ptr vw(renderer->getViewer()); if (vw) { @@ -230,6 +206,10 @@ FGGlobals::~FGGlobals() vw->stopThreading(); } + subsystem_mgr->shutdown(); + subsystem_mgr->unbind(); + + 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()) { @@ -238,11 +218,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; subsystem_mgr = NULL; // important so ::get_subsystem returns NULL @@ -253,7 +232,6 @@ FGGlobals::~FGGlobals() delete channel_options_list; delete initial_waypoints; - delete fontcache; delete channellist; simgear::PropertyObjectBase::setDefaultRoot(NULL); @@ -375,6 +353,11 @@ void FGGlobals::append_fg_scenery (const std::string &paths, bool secure) continue; } + // tell the ResouceManager about the scenery path + // needed to load Models from this scenery path + simgear::ResourceManager::instance()->addBasePath(abspath.str(), + simgear::ResourceManager::PRIORITY_DEFAULT); + simgear::Dir dir(abspath); SGPath terrainDir(dir.file("Terrain")); SGPath objectsDir(dir.file("Objects")); @@ -524,12 +507,6 @@ FGGlobals::add_subsystem (const char * name, subsystem_mgr->add(name, subsystem, type, min_time_sec); } -SGSoundMgr * -FGGlobals::get_soundmgr () const -{ - return get_subsystem(); -} - SGEventMgr * FGGlobals::get_event_mgr () const { @@ -694,12 +671,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 +693,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 ) +flightgear::View* 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 ) @@ -750,16 +722,6 @@ FGControls *FGGlobals::get_controls() const return get_subsystem(); } -FGSampleQueue* FGGlobals::get_chatter_queue() const -{ - return _chatter_queue; -} - -void FGGlobals::set_chatter_queue(FGSampleQueue* queue) -{ - _chatter_queue = queue; -} - void FGGlobals::addListenerToCleanup(SGPropertyChangeListener* l) { _listeners_to_cleanup.push_back(l);