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 <algorithm> to top of ModelRegistry.cxx. Change include syntax in PathOptions.cxx
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include <osgDB/Registry>
|
#include <osgDB/Registry>
|
||||||
|
|
||||||
#include <PathOptions.hxx>
|
#include "PathOptions.hxx"
|
||||||
|
|
||||||
using namespace simgear;
|
using namespace simgear;
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "ModelRegistry.hxx"
|
#include "ModelRegistry.hxx"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <OpenThreads/ScopedLock>
|
#include <OpenThreads/ScopedLock>
|
||||||
|
|
||||||
#include <osg/observer_ptr>
|
#include <osg/observer_ptr>
|
||||||
@@ -219,7 +221,7 @@ struct OptionsPusher {
|
|||||||
++iter) {
|
++iter) {
|
||||||
if (find(regPathList.begin(), regPathList.end(), *iter)
|
if (find(regPathList.begin(), regPathList.end(), *iter)
|
||||||
== regPathList.end())
|
== regPathList.end())
|
||||||
localPathList.push_front(*iter);
|
localPathList.push_back(*iter);
|
||||||
}
|
}
|
||||||
// Save the current Registry path list and install the augmented one.
|
// Save the current Registry path list and install the augmented one.
|
||||||
localPathList.swap(registry->getDataFilePathList());
|
localPathList.swap(registry->getDataFilePathList());
|
||||||
@@ -242,27 +244,29 @@ ModelRegistry::readImage(const string& fileName,
|
|||||||
CallbackMap::iterator iter
|
CallbackMap::iterator iter
|
||||||
= imageCallbackMap.find(getFileExtension(fileName));
|
= imageCallbackMap.find(getFileExtension(fileName));
|
||||||
// XXX Workaround for OSG plugin bug
|
// XXX Workaround for OSG plugin bug
|
||||||
OptionsPusher pusher(opt);
|
{
|
||||||
if (iter != imageCallbackMap.end() && iter->second.valid())
|
OptionsPusher pusher(opt);
|
||||||
return iter->second->readImage(fileName, opt);
|
if (iter != imageCallbackMap.end() && iter->second.valid())
|
||||||
string absFileName = findDataFile(fileName);
|
return iter->second->readImage(fileName, opt);
|
||||||
if (!fileExists(absFileName)) {
|
string absFileName = findDataFile(fileName);
|
||||||
SG_LOG(SG_IO, SG_ALERT, "Cannot find image file \""
|
if (!fileExists(absFileName)) {
|
||||||
<< fileName << "\"");
|
SG_LOG(SG_IO, SG_ALERT, "Cannot find image file \""
|
||||||
return ReaderWriter::ReadResult::FILE_NOT_FOUND;
|
<< 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() << "\"");
|
||||||
|
|
||||||
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user