From 40d46a86874cf426edf6e77fd133a4f4bc2d7451 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 20 Nov 2009 14:51:43 +0000 Subject: [PATCH] From Chris Hanson, " Remove vestigial (and because it was undocumented, potentially harmful) code to ignore filenames starting with a dash "-" character from the (std::vector&) version of osgDB::readNodeFiles. Handling of argument strings is properly implemented in the osgDB::readNodeFiles(osg::ArgumentParser& arguments,const Options* options) variant, which most code uses. The (std::vector&) version is only called by the osgconv utility, which does its own argument handling and stripping prior to calling readNodeFiles(). Also, documented this behaviour in the header comments. I believe this code removal is a meritful change because leavign the code in causes an unexpected and undocumented behaviour (ignoring any filename starting with a dash) that could bite users in the future. This behaviour is not needed for existing functionality because existing code uses other APIs to handle dash-prefixed arguments anyway. " --- include/osgDB/ReadFile | 9 +++++---- src/osgDB/ReadFile.cpp | 24 +++++++++--------------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/include/osgDB/ReadFile b/include/osgDB/ReadFile index 711157093..01a26ce97 100644 --- a/include/osgDB/ReadFile +++ b/include/osgDB/ReadFile @@ -109,14 +109,15 @@ inline osg::Node* readNodeFile(const std::string& filename) /** Read an osg::Node subgraph from files, creating a osg::Group to contain the nodes if more * than one subgraph has been loaded. - * Use the Options object to control cache operations and file search paths in osgDB::Registry.*/ -extern OSGDB_EXPORT osg::Node* readNodeFiles(std::vector& commandLine,const Options* options); + * Use the Options object to control cache operations and file search paths in osgDB::Registry. + * Does NOT ignore strings beginning with a dash '-' character. */ +extern OSGDB_EXPORT osg::Node* readNodeFiles(std::vector& fileList,const Options* options); /** Read an osg::Node subgraph from files, creating a osg::Group to contain the nodes if more * than one subgraph has been loaded.*/ -inline osg::Node* readNodeFiles(std::vector& commandLine) +inline osg::Node* readNodeFiles(std::vector& fileList) { - return readNodeFiles(commandLine,Registry::instance()->getOptions()); + return readNodeFiles(fileList,Registry::instance()->getOptions()); } diff --git a/src/osgDB/ReadFile.cpp b/src/osgDB/ReadFile.cpp index a4586d239..6fda6f40d 100644 --- a/src/osgDB/ReadFile.cpp +++ b/src/osgDB/ReadFile.cpp @@ -72,29 +72,23 @@ Node* osgDB::readNodeFile(const std::string& filename,const Options* options) return NULL; } -Node* osgDB::readNodeFiles(std::vector& commandLine,const Options* options) +Node* osgDB::readNodeFiles(std::vector& fileList,const Options* options) { typedef std::vector NodeList; NodeList nodeList; - // note currently doesn't delete the loaded file entries from the command line yet... - - for(std::vector::iterator itr=commandLine.begin(); - itr!=commandLine.end(); + for(std::vector::iterator itr=fileList.begin(); + itr!=fileList.end(); ++itr) { - if ((*itr)[0]!='-') + osg::Node *node = osgDB::readNodeFile( *itr , Registry::instance()->getOptions() ); + + if( node != (osg::Node *)0L ) { - // not an option so assume string is a filename. - osg::Node *node = osgDB::readNodeFile( *itr , options ); - - if( node != (osg::Node *)0L ) - { - if (node->getName().empty()) node->setName( *itr ); - nodeList.push_back(node); - } - + if (node->getName().empty()) node->setName( *itr ); + nodeList.push_back(node); } + } if (nodeList.empty())