]> git.mxchange.org Git - flightgear.git/blobdiff - src/Scenery/tilemgr.cxx
Crash-fix: mat-lib is now reference-counted.
[flightgear.git] / src / Scenery / tilemgr.cxx
index 3df77c0e531c3d753d148ce2fd167cc4f4f8081b..ce3fd774225ae99947964859b21b32c02a144925 100644 (file)
@@ -86,7 +86,8 @@ void FGTileMgr::init() {
     SG_LOG( SG_TERRAIN, SG_INFO, "Initializing Tile Manager subsystem." );
 
     _options = new simgear::SGReaderWriterOptions;
-    _options->setMaterialLib(globals->get_matlib());
+    
+    materialLibChanged();
     _options->setPropertyNode(globals->get_props());
 
     osgDB::FilePathList &fp = _options->getDatabasePathList();
@@ -116,8 +117,7 @@ void FGTileMgr::reinit()
     fgSetBool("/sim/sceneryloaded",false);
     fgSetDouble("/sim/startup/splash-alpha", 1.0);
     
-    // Reload the materials definitions
-    _options->setMaterialLib(globals->get_matlib());
+    materialLibChanged();
 
     // remove all old scenery nodes from scenegraph and clear cache
     osg::Group* group = globals->get_scenery()->get_terrain_branch();
@@ -141,6 +141,12 @@ void FGTileMgr::reinit()
     update(0.0);
 }
 
+void FGTileMgr::materialLibChanged()
+{
+    _options->setMaterialLib(globals->get_matlib());
+    _options->getMaterialLib()->refreshActiveMaterials();
+}
+
 /* schedule a tile for loading, keep request for given amount of time.
  * Returns true if tile is already loaded. */
 bool FGTileMgr::sched_tile( const SGBucket& b, double priority, bool current_view, double duration)