From: James Turner Date: Thu, 21 Nov 2013 17:38:22 +0000 (+0000) Subject: Reset: delete mat-lib, re-create on reset X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=1d8b080782f736e1d66a488750f0f16caac304b5;p=flightgear.git Reset: delete mat-lib, re-create on reset --- diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index d131d1e9b..d65092bfe 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -615,13 +615,11 @@ void fgCreateSubsystems(bool duringReset) { // Initialize the material property subsystem. //////////////////////////////////////////////////////////////////// - if (!duringReset) { - SGPath mpath( globals->get_fg_root() ); - mpath.append( fgGetString("/sim/rendering/materials-file") ); - if ( ! globals->get_matlib()->load(globals->get_fg_root(), mpath.str(), - globals->get_props()) ) { - throw sg_io_exception("Error loading materials file", mpath); - } + SGPath mpath( globals->get_fg_root() ); + mpath.append( fgGetString("/sim/rendering/materials-file") ); + if ( ! globals->get_matlib()->load(globals->get_fg_root(), mpath.str(), + globals->get_props()) ) { + throw sg_io_exception("Error loading materials file", mpath); } globals->add_subsystem( "http", new FGHTTPClient ); @@ -980,6 +978,7 @@ void fgStartNewReset() osg::ref_ptr eventHandler = render->getEventHandler(); globals->set_renderer(NULL); + globals->set_matlib(NULL); simgear::SGModelLib::resetPropertyRoot(); globals->resetPropertyRoot(); @@ -1004,6 +1003,8 @@ void fgStartNewReset() globals->get_event_mgr()->init(); globals->get_event_mgr()->setRealtimeProperty(fgGetNode("/sim/time/delta-realtime-sec", true)); + globals->set_matlib( new SGMaterialLib ); + // terra-sync needs the property tree root, pass it back in simgear::SGTerraSync* terra_sync = static_cast(subsystemManger->get_subsystem("terrasync")); terra_sync->setRoot(globals->get_props()); diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index 909c83fb6..ee639d64a 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -215,7 +215,7 @@ FGGlobals::~FGGlobals() subsystem_mgr = NULL; // important so ::get_subsystem returns NULL delete time_params; - delete matlib; + set_matlib(NULL); delete route_mgr; delete ATIS_mgr; delete channel_options_list; @@ -688,4 +688,11 @@ void FGGlobals::set_tile_mgr ( FGTileMgr *t ) _tile_mgr = t; } +void FGGlobals::set_matlib( SGMaterialLib *m ) +{ + if (matlib) + delete matlib; + matlib = m; +} + // end of globals.cxx diff --git a/src/Main/globals.hxx b/src/Main/globals.hxx index f6cc5bfd9..09275daae 100644 --- a/src/Main/globals.hxx +++ b/src/Main/globals.hxx @@ -261,7 +261,7 @@ public: inline void set_ephem( SGEphemeris *e ) { ephem = e; } inline SGMaterialLib *get_matlib() const { return matlib; } - inline void set_matlib( SGMaterialLib *m ) { matlib = m; } + void set_matlib( SGMaterialLib *m ); inline FGATISMgr *get_ATIS_mgr() const { return ATIS_mgr; } inline void set_ATIS_mgr( FGATISMgr *a ) {ATIS_mgr = a; }