From 5d6ce1a25fcfa8de91f90be2a5201a839962e5ed Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 27 Nov 2009 12:17:20 +0000 Subject: [PATCH] From Cory Riddell, "Small edit to ReaderWriterDOT.cpp. It wasn't checking the file extension and so, if the .dot plugin was loaded, it would happily handle any file name extension. To reproduce the bug, first save a scene to a dot file (to load the dot plugin), then try to write the scene to an osg file. If you look at the osg file, you will see that it is a dot file." --- src/osgPlugins/dot/ReaderWriterDOT.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/osgPlugins/dot/ReaderWriterDOT.cpp b/src/osgPlugins/dot/ReaderWriterDOT.cpp index adef25ea2..1382bfc84 100644 --- a/src/osgPlugins/dot/ReaderWriterDOT.cpp +++ b/src/osgPlugins/dot/ReaderWriterDOT.cpp @@ -21,6 +21,11 @@ class ReaderWriterDOT : public osgDB::ReaderWriter { virtual bool acceptsExtension(const std::string& extension) const { return osgDB::equalCaseInsensitive(extension,"dot"); } virtual WriteResult writeNode(const osg::Node& node,const std::string& fileName,const Options* options = NULL) const { + std::string ext = osgDB::getFileExtension(fileName); + if (!acceptsExtension(ext)) { + return WriteResult::FILE_NOT_HANDLED; + } + std::ofstream o( fileName.c_str(), std::ios_base::out ); if ( o ) { return writeNode( node, o, options );