From 1159784538da59bf3cc3d4cf918078a21e23df64 Mon Sep 17 00:00:00 2001 From: timoore Date: Tue, 11 Dec 2007 11:07:21 +0000 Subject: [PATCH] minor fix to ModelRegistry and syntax changes for Windows Create the local path in the right order in OptionsPusher. When OptionsPusher is used, put it inside a new code block so the order of destruction with respect to the mutex on reader functions id clear. Add #include to top of ModelRegistry.cxx. Change include syntax in PathOptions.cxx --- simgear/misc/PathOptions.cxx | 2 +- simgear/scene/model/ModelRegistry.cxx | 46 +++++++++++++++------------ 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/simgear/misc/PathOptions.cxx b/simgear/misc/PathOptions.cxx index a74ae94a..32c719d6 100644 --- a/simgear/misc/PathOptions.cxx +++ b/simgear/misc/PathOptions.cxx @@ -19,7 +19,7 @@ #include -#include +#include "PathOptions.hxx" using namespace simgear; diff --git a/simgear/scene/model/ModelRegistry.cxx b/simgear/scene/model/ModelRegistry.cxx index 0ac69685..1b9eebeb 100644 --- a/simgear/scene/model/ModelRegistry.cxx +++ b/simgear/scene/model/ModelRegistry.cxx @@ -18,6 +18,8 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "ModelRegistry.hxx" +#include + #include #include @@ -219,7 +221,7 @@ struct OptionsPusher { ++iter) { if (find(regPathList.begin(), regPathList.end(), *iter) == regPathList.end()) - localPathList.push_front(*iter); + localPathList.push_back(*iter); } // Save the current Registry path list and install the augmented one. localPathList.swap(registry->getDataFilePathList()); @@ -242,27 +244,29 @@ ModelRegistry::readImage(const string& fileName, CallbackMap::iterator iter = imageCallbackMap.find(getFileExtension(fileName)); // XXX Workaround for OSG plugin bug - OptionsPusher pusher(opt); - if (iter != imageCallbackMap.end() && iter->second.valid()) - return iter->second->readImage(fileName, opt); - string absFileName = findDataFile(fileName); - if (!fileExists(absFileName)) { - SG_LOG(SG_IO, SG_ALERT, "Cannot find image file \"" - << fileName << "\""); - return ReaderWriter::ReadResult::FILE_NOT_FOUND; - } - - Registry* registry = Registry::instance(); - ReaderWriter::ReadResult res; - res = registry->readImageImplementation(absFileName, opt); - if (res.loadedFromCache()) - SG_LOG(SG_IO, SG_INFO, "Returning cached image \"" - << res.getImage()->getFileName() << "\""); - else - SG_LOG(SG_IO, SG_INFO, "Reading image \"" - << res.getImage()->getFileName() << "\""); + { + OptionsPusher pusher(opt); + if (iter != imageCallbackMap.end() && iter->second.valid()) + return iter->second->readImage(fileName, opt); + string absFileName = findDataFile(fileName); + if (!fileExists(absFileName)) { + SG_LOG(SG_IO, SG_ALERT, "Cannot find image file \"" + << fileName << "\""); + return ReaderWriter::ReadResult::FILE_NOT_FOUND; + } - return res; + Registry* registry = Registry::instance(); + ReaderWriter::ReadResult res; + res = registry->readImageImplementation(absFileName, opt); + if (res.loadedFromCache()) + SG_LOG(SG_IO, SG_INFO, "Returning cached image \"" + << res.getImage()->getFileName() << "\""); + else + SG_LOG(SG_IO, SG_INFO, "Reading image \"" + << res.getImage()->getFileName() << "\""); + + return res; + } } -- 2.39.5