From: timoore Date: Mon, 10 Dec 2007 08:30:43 +0000 (+0000) Subject: Check for null options before changing path in registry X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e683b5fdec3d0ca58b11766085829970e9e22bf4;p=simgear.git Check for null options before changing path in registry --- diff --git a/simgear/scene/model/ModelRegistry.cxx b/simgear/scene/model/ModelRegistry.cxx index 6ae694b8..0ac69685 100644 --- a/simgear/scene/model/ModelRegistry.cxx +++ b/simgear/scene/model/ModelRegistry.cxx @@ -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