]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/fg_commands.cxx
Crash-fix: mat-lib is now reference-counted.
[flightgear.git] / src / Main / fg_commands.cxx
index 6ae72a99622eb6ee7a6f4f6a7e057a3007673119..efbb4a97124c253c514dae1e263fc65f9540c399 100644 (file)
@@ -31,6 +31,7 @@
 #include <GUI/dialog.hxx>
 #include <Aircraft/replay.hxx>
 #include <Scenery/scenery.hxx>
+#include <Scenery/tilemgr.hxx>
 #include <Scripting/NasalSys.hxx>
 #include <Sound/sample_queue.hxx>
 #include <Airports/xmlloader.hxx>
@@ -500,26 +501,29 @@ do_tile_cache_reload (const SGPropertyNode * arg)
 /**
  * Reload the materials definition
  */
- static bool
- do_materials_reload (const SGPropertyNode * arg)
- {
-   SG_LOG(SG_INPUT, SG_INFO, "Reloading Materials");
-   SGMaterialLib* new_matlib =  new SGMaterialLib;
-   SGPath mpath( globals->get_fg_root() );
-   mpath.append( fgGetString("/sim/rendering/materials-file") );
-   bool loaded = new_matlib->load(globals->get_fg_root(), 
+static bool
+do_materials_reload (const SGPropertyNode * arg)
+{
+    SG_LOG(SG_INPUT, SG_INFO, "Reloading Materials");
+    SGMaterialLib* new_matlib =  new SGMaterialLib;
+    SGPath mpath( globals->get_fg_root() );
+    mpath.append( fgGetString("/sim/rendering/materials-file") );
+    bool loaded = new_matlib->load(globals->get_fg_root(), 
                                   mpath.str(), 
                                   globals->get_props());
-   
-   if ( ! loaded ) {
+
+    if ( ! loaded ) {
        SG_LOG( SG_GENERAL, SG_ALERT,
                "Error loading materials file " << mpath.str() );
        return false;
-   }  
-   
-   globals->set_matlib(new_matlib);    
-   return true;   
- }
+    }  
+
+    globals->set_matlib(new_matlib);    
+    FGTileMgr* tileManager = static_cast<FGTileMgr*>(globals->get_subsystem("tile-manager"));
+    tileManager->materialLibChanged();
+    
+    return true;
+}
 
 
 #if 0
@@ -1164,10 +1168,11 @@ do_play_audio_sample (const SGPropertyNode * arg)
     float volume = arg->getFloatValue("volume");
     // cout << "playing " << path << " / " << file << endl;
     try {
-        static FGSampleQueue *queue = 0;
+        FGSampleQueue *queue = globals->get_chatter_queue();
         if ( !queue ) {
-           queue = new FGSampleQueue(smgr, "chatter");
-           queue->tie_to_listener();
+            queue = new FGSampleQueue(smgr, "chatter");
+            queue->tie_to_listener();
+            globals->set_chatter_queue(queue);
         }
 
         SGSoundSample *msg = new SGSoundSample(file.c_str(), path);