From 811f156ad1c4a51eedc382959446b72451827abe Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sat, 11 Feb 2012 10:55:13 +0100 Subject: [PATCH] #658: better bugfix for findDataFile issue Fixes the more basic probelm of "SGModelLib::findDataFile" resolving an empty file name to the fgdata (directory) path. findData_File_ should never return a _directory_ path, only valid _file_ names. --- simgear/scene/material/TextureBuilder.cxx | 11 ++++------- simgear/scene/model/modellib.cxx | 6 ++++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/simgear/scene/material/TextureBuilder.cxx b/simgear/scene/material/TextureBuilder.cxx index ad3ad569..0c141c47 100644 --- a/simgear/scene/material/TextureBuilder.cxx +++ b/simgear/scene/material/TextureBuilder.cxx @@ -216,14 +216,11 @@ TexTuple makeTexTuple(Effect* effect, const SGPropertyNode* props, if (pImage) { imageName = pImage->getStringValue(); - if (!imageName.empty()) + absFileName = SGModelLib::findDataFile(imageName, options); + if (absFileName.empty()) { - absFileName = SGModelLib::findDataFile(imageName, options); - if (absFileName.empty()) - { - SG_LOG(SG_INPUT, SG_ALERT, "Texture file not found: '" - << imageName << "'"); - } + SG_LOG(SG_INPUT, SG_ALERT, "Texture file not found: '" + << imageName << "'"); } } diff --git a/simgear/scene/model/modellib.cxx b/simgear/scene/model/modellib.cxx index 5fa40fca..68872550 100644 --- a/simgear/scene/model/modellib.cxx +++ b/simgear/scene/model/modellib.cxx @@ -68,11 +68,13 @@ std::string SGModelLib::findDataFile(const std::string& file, const osgDB::ReaderWriter::Options* opts, SGPath currentPath) { + if (file.empty()) + return file; SGPath p = ResourceManager::instance()->findPath(file, currentPath); - if (p.exists()) { + if (p.exists()&&p.isFile()) { return p.str(); } - + // finally hand on to standard OSG behaviour return osgDB::findDataFile(file, opts); } -- 2.39.5