]> git.mxchange.org Git - flightgear.git/commitdiff
Reset: delete mat-lib, re-create on reset
authorJames Turner <zakalawe@mac.com>
Thu, 21 Nov 2013 17:38:22 +0000 (17:38 +0000)
committerJames Turner <zakalawe@mac.com>
Fri, 22 Nov 2013 22:52:29 +0000 (22:52 +0000)
src/Main/fg_init.cxx
src/Main/globals.cxx
src/Main/globals.hxx

index d131d1e9b1b04d9b166470199f54552a91ed44ad..d65092bfe5ce780edfa1cc2ea4abc8c7fc0c53e0 100644 (file)
@@ -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<flightgear::FGEventHandler> 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<simgear::SGTerraSync*>(subsystemManger->get_subsystem("terrasync"));
     terra_sync->setRoot(globals->get_props());
index 909c83fb662157b84911850e2d10e8442968824f..ee639d64a406922582de670ae80916e806df606d 100644 (file)
@@ -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
index f6cc5bfd99bdfedb960123ef5cb9154a9f23ccad..09275daae10ebd108c6d9bf110f3239b3bff79cc 100644 (file)
@@ -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; }