]> git.mxchange.org Git - simgear.git/commitdiff
Check for null options before changing path in registry
authortimoore <timoore>
Mon, 10 Dec 2007 08:30:43 +0000 (08:30 +0000)
committertimoore <timoore>
Mon, 10 Dec 2007 08:30:43 +0000 (08:30 +0000)
simgear/scene/model/ModelRegistry.cxx

index 6ae694b8e6a9682355512d14c5617fbec287b3b4..0ac69685acfeeb9b744e60f3e6ea77cbe8233f9c 100644 (file)
@@ -204,8 +204,12 @@ public:
 
 struct OptionsPusher {
     FilePathList localPathList;
-    OptionsPusher(const ReaderWriter::Options* options)
+    bool validOptions;
+    OptionsPusher(const ReaderWriter::Options* options):
+        validOptions(false)
     {
+        if (!options)
+            return;
         Registry* registry = Registry::instance();
         localPathList = registry->getDataFilePathList();
         const FilePathList& regPathList = registry->getDataFilePathList();
@@ -219,11 +223,13 @@ struct OptionsPusher {
         }
         // Save the current Registry path list and install the augmented one.
         localPathList.swap(registry->getDataFilePathList());
+        validOptions = true;
     }
     ~OptionsPusher()
     {
         // Restore the old path list
-        localPathList.swap(Registry::instance()->getDataFilePathList());
+        if (validOptions)
+            localPathList.swap(Registry::instance()->getDataFilePathList());
     }
 };
 } // namespace