From f49e1d32c9a7c5c49d9f0c0b2cbaa14c944e9f66 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sat, 5 May 2018 12:28:45 +0100 Subject: [PATCH] Replaced std::auto_ptr<> usage as it's deprecated in C++11 and will be removed in C++17 --- include/osgDB/Registry | 2 +- src/osgDB/Registry.cpp | 2 +- src/osgPlugins/OpenFlight/FltExportVisitor.h | 8 ++++---- .../OpenFlight/LightSourcePaletteManager.h | 2 +- src/osgPlugins/OpenFlight/MaterialPaletteManager.h | 5 ++++- src/osgPlugins/OpenFlight/TexturePaletteManager.h | 2 +- src/osgPlugins/OpenFlight/VertexPaletteManager.h | 5 +++-- src/osgPlugins/dae/CMakeLists.txt | 4 ++++ src/osgPlugins/dae/ReaderWriterDAE.cpp | 12 +++++++++--- src/osgPlugins/stl/ReaderWriterSTL.cpp | 4 ++-- 10 files changed, 30 insertions(+), 16 deletions(-) diff --git a/include/osgDB/Registry b/include/osgDB/Registry index 87076dc81..2829ca61d 100644 --- a/include/osgDB/Registry +++ b/include/osgDB/Registry @@ -554,7 +554,7 @@ class OSGDB_EXPORT Registry : public osg::Referenced public: /** Functor used in internal implementations.*/ - struct ReadFunctor + struct ReadFunctor : public osg::Referenced { ReadFunctor(const std::string& filename, const Options* options): _filename(filename), diff --git a/src/osgDB/Registry.cpp b/src/osgDB/Registry.cpp index e0dca390d..db62c7b10 100644 --- a/src/osgDB/Registry.cpp +++ b/src/osgDB/Registry.cpp @@ -1168,7 +1168,7 @@ ReaderWriter::ReadResult Registry::read(const ReadFunctor& readFunctor) options->setDatabasePath(archiveName); - std::auto_ptr rf(readFunctor.cloneType(fileName, options.get())); + osg::ref_ptr rf(readFunctor.cloneType(fileName, options.get())); result = rf->doRead(*archive); diff --git a/src/osgPlugins/OpenFlight/FltExportVisitor.h b/src/osgPlugins/OpenFlight/FltExportVisitor.h index 4de2b84a1..7237c0e7c 100644 --- a/src/osgPlugins/OpenFlight/FltExportVisitor.h +++ b/src/osgPlugins/OpenFlight/FltExportVisitor.h @@ -184,10 +184,10 @@ private: typedef std::vector< osg::ref_ptr > StateSetStack; StateSetStack _stateSetStack; - std::auto_ptr _materialPalette; - std::auto_ptr _texturePalette; - std::auto_ptr _lightSourcePalette; - std::auto_ptr _vertexPalette; + osg::ref_ptr _materialPalette; + osg::ref_ptr _texturePalette; + osg::ref_ptr _lightSourcePalette; + osg::ref_ptr _vertexPalette; // Used to avoid duplicate Header/Group records at top of output FLT file. bool _firstNode; diff --git a/src/osgPlugins/OpenFlight/LightSourcePaletteManager.h b/src/osgPlugins/OpenFlight/LightSourcePaletteManager.h index 24f028ff8..029aae5d5 100644 --- a/src/osgPlugins/OpenFlight/LightSourcePaletteManager.h +++ b/src/osgPlugins/OpenFlight/LightSourcePaletteManager.h @@ -33,7 +33,7 @@ namespace flt class DataOutputStream; -class LightSourcePaletteManager +class LightSourcePaletteManager : public osg::Referenced { public: LightSourcePaletteManager(); diff --git a/src/osgPlugins/OpenFlight/MaterialPaletteManager.h b/src/osgPlugins/OpenFlight/MaterialPaletteManager.h index 2af2a14a6..b9801f77b 100644 --- a/src/osgPlugins/OpenFlight/MaterialPaletteManager.h +++ b/src/osgPlugins/OpenFlight/MaterialPaletteManager.h @@ -32,7 +32,7 @@ namespace flt class DataOutputStream; -class MaterialPaletteManager +class MaterialPaletteManager : public osg::Referenced { public: MaterialPaletteManager( ExportOptions& fltOpt ); @@ -45,6 +45,9 @@ class MaterialPaletteManager private: + + virtual ~MaterialPaletteManager() {} + int _currIndex; // Helper struct to hold material palette records diff --git a/src/osgPlugins/OpenFlight/TexturePaletteManager.h b/src/osgPlugins/OpenFlight/TexturePaletteManager.h index f4b2fcd1f..7589ce267 100644 --- a/src/osgPlugins/OpenFlight/TexturePaletteManager.h +++ b/src/osgPlugins/OpenFlight/TexturePaletteManager.h @@ -35,7 +35,7 @@ class DataOutputStream; class FltExportVisitor; -class TexturePaletteManager +class TexturePaletteManager : public osg::Referenced { public: TexturePaletteManager( const FltExportVisitor& nv, const ExportOptions& fltOpt ); diff --git a/src/osgPlugins/OpenFlight/VertexPaletteManager.h b/src/osgPlugins/OpenFlight/VertexPaletteManager.h index 47c603e80..8cfb110ae 100644 --- a/src/osgPlugins/OpenFlight/VertexPaletteManager.h +++ b/src/osgPlugins/OpenFlight/VertexPaletteManager.h @@ -40,11 +40,10 @@ namespace flt file and copies it to FltExportVisitor::_dos after the scene graph has been completely walked. */ -class VertexPaletteManager +class VertexPaletteManager : public osg::Referenced { public: VertexPaletteManager( const ExportOptions& fltOpt ); - ~VertexPaletteManager(); void add( const osg::Geometry& geom ); void add( const osg::Array* key, @@ -66,6 +65,8 @@ public: static osg::ref_ptr< const osg::Vec4Array > asVec4Array( const osg::Array* in, const unsigned int n ); protected: + virtual ~VertexPaletteManager(); + typedef enum { VERTEX_C, VERTEX_CN, diff --git a/src/osgPlugins/dae/CMakeLists.txt b/src/osgPlugins/dae/CMakeLists.txt index 4e66afce7..af03fb866 100644 --- a/src/osgPlugins/dae/CMakeLists.txt +++ b/src/osgPlugins/dae/CMakeLists.txt @@ -9,6 +9,10 @@ IF(CMAKE_COMPILER_IS_GNUCXX) STRING(REGEX REPLACE "-Wextra" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") ENDIF() +IF(CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") +ENDIF() + SET(TARGET_SRC daeReader.cpp diff --git a/src/osgPlugins/dae/ReaderWriterDAE.cpp b/src/osgPlugins/dae/ReaderWriterDAE.cpp index 1d63d1060..d3111dc7f 100644 --- a/src/osgPlugins/dae/ReaderWriterDAE.cpp +++ b/src/osgPlugins/dae/ReaderWriterDAE.cpp @@ -32,6 +32,11 @@ #define SERIALIZER() OpenThreads::ScopedLock lock(_serializerMutex) +#if __cplusplus > 199711L + #define smart_ptr std::unique_ptr +#else + #define smart_prt std::auto_ptr +#endif osgDB::ReaderWriter::ReadResult ReaderWriterDAE::readNode(std::istream& fin, @@ -73,7 +78,7 @@ ReaderWriterDAE::readNode(std::istream& fin, #endif } - std::auto_ptr scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit + smart_ptr scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit osgDAE::daeReader daeReader(pDAE, &pluginOptions); @@ -150,7 +155,8 @@ ReaderWriterDAE::readNode(const std::string& fname, pDAE = new DAE; #endif } - std::auto_ptr scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit + + smart_ptr scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit osgDAE::daeReader daeReader(pDAE, &pluginOptions); @@ -247,7 +253,7 @@ ReaderWriterDAE::writeNode( const osg::Node& node, pDAE = new DAE; #endif } - std::auto_ptr scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit + smart_ptr scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit // Convert file name to URI std::string fileURI = ConvertFilePathToColladaCompatibleURI(fname); diff --git a/src/osgPlugins/stl/ReaderWriterSTL.cpp b/src/osgPlugins/stl/ReaderWriterSTL.cpp index 7d7571086..a4cae46fc 100644 --- a/src/osgPlugins/stl/ReaderWriterSTL.cpp +++ b/src/osgPlugins/stl/ReaderWriterSTL.cpp @@ -113,7 +113,7 @@ public: virtual WriteResult writeNode(const osg::Node& node, const std::string& fileName, const Options* = NULL) const; private: - class ReaderObject + class ReaderObject : public osg::Referenced { public: ReaderObject(bool noTriStripPolygons, bool generateNormals = true): @@ -526,7 +526,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterSTL::readNode(const std::string& fil else readerObject = new AsciiReaderObject(localOptions.noTriStripPolygons); - std::auto_ptr readerPtr(readerObject); + osg::ref_ptr readerPtr(readerObject); while (1) {