]> git.mxchange.org Git - simgear.git/commitdiff
#658: better bugfix for findDataFile issue
authorThorstenB <brehmt@gmail.com>
Sat, 11 Feb 2012 09:55:13 +0000 (10:55 +0100)
committerThorstenB <brehmt@gmail.com>
Sat, 11 Feb 2012 09:55:13 +0000 (10:55 +0100)
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
simgear/scene/model/modellib.cxx

index ad3ad56909d22366de1d57a3373ecf311fa27af1..0c141c475c3415b627c354ad8cb53b4a1d52eb69 100644 (file)
@@ -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 << "'");
         }
     }
 
index 5fa40fca2e5b296f24ec315face10c32949033e0..68872550b4747bbefc5db53570ee86ccabf84f0b 100644 (file)
@@ -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);
 }