Skip to content

Commit 863dee5

Browse files
committed
Replaced std::auto_ptr<> usage as it's deprecated in C++11 and will be removed in C++17
1 parent a1c8a3e commit 863dee5

File tree

10 files changed

+30
-16
lines changed

10 files changed

+30
-16
lines changed

include/osgDB/Registry

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ class OSGDB_EXPORT Registry : public osg::Referenced
554554

555555
public:
556556
/** Functor used in internal implementations.*/
557-
struct ReadFunctor
557+
struct ReadFunctor : public osg::Referenced
558558
{
559559
ReadFunctor(const std::string& filename, const Options* options):
560560
_filename(filename),

src/osgDB/Registry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,7 @@ ReaderWriter::ReadResult Registry::read(const ReadFunctor& readFunctor)
11691169

11701170
options->setDatabasePath(archiveName);
11711171

1172-
std::auto_ptr<ReadFunctor> rf(readFunctor.cloneType(fileName, options.get()));
1172+
osg::ref_ptr<ReadFunctor> rf(readFunctor.cloneType(fileName, options.get()));
11731173

11741174
result = rf->doRead(*archive);
11751175

src/osgPlugins/OpenFlight/FltExportVisitor.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,10 @@ class FltExportVisitor : public osg::NodeVisitor
184184
typedef std::vector< osg::ref_ptr<osg::StateSet> > StateSetStack;
185185
StateSetStack _stateSetStack;
186186

187-
std::auto_ptr<MaterialPaletteManager> _materialPalette;
188-
std::auto_ptr<TexturePaletteManager> _texturePalette;
189-
std::auto_ptr<LightSourcePaletteManager> _lightSourcePalette;
190-
std::auto_ptr<VertexPaletteManager> _vertexPalette;
187+
osg::ref_ptr<MaterialPaletteManager> _materialPalette;
188+
osg::ref_ptr<TexturePaletteManager> _texturePalette;
189+
osg::ref_ptr<LightSourcePaletteManager> _lightSourcePalette;
190+
osg::ref_ptr<VertexPaletteManager> _vertexPalette;
191191

192192
// Used to avoid duplicate Header/Group records at top of output FLT file.
193193
bool _firstNode;

src/osgPlugins/OpenFlight/LightSourcePaletteManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace flt
3333
class DataOutputStream;
3434

3535

36-
class LightSourcePaletteManager
36+
class LightSourcePaletteManager : public osg::Referenced
3737
{
3838
public:
3939
LightSourcePaletteManager();

src/osgPlugins/OpenFlight/MaterialPaletteManager.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace flt
3232
class DataOutputStream;
3333

3434

35-
class MaterialPaletteManager
35+
class MaterialPaletteManager : public osg::Referenced
3636
{
3737
public:
3838
MaterialPaletteManager( ExportOptions& fltOpt );
@@ -45,6 +45,9 @@ class MaterialPaletteManager
4545

4646

4747
private:
48+
49+
virtual ~MaterialPaletteManager() {}
50+
4851
int _currIndex;
4952

5053
// Helper struct to hold material palette records

src/osgPlugins/OpenFlight/TexturePaletteManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class DataOutputStream;
3535
class FltExportVisitor;
3636

3737

38-
class TexturePaletteManager
38+
class TexturePaletteManager : public osg::Referenced
3939
{
4040
public:
4141
TexturePaletteManager( const FltExportVisitor& nv, const ExportOptions& fltOpt );

src/osgPlugins/OpenFlight/VertexPaletteManager.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@ namespace flt
4040
file and copies it to FltExportVisitor::_dos after the scene graph
4141
has been completely walked.
4242
*/
43-
class VertexPaletteManager
43+
class VertexPaletteManager : public osg::Referenced
4444
{
4545
public:
4646
VertexPaletteManager( const ExportOptions& fltOpt );
47-
~VertexPaletteManager();
4847

4948
void add( const osg::Geometry& geom );
5049
void add( const osg::Array* key,
@@ -66,6 +65,8 @@ class VertexPaletteManager
6665
static osg::ref_ptr< const osg::Vec4Array > asVec4Array( const osg::Array* in, const unsigned int n );
6766

6867
protected:
68+
virtual ~VertexPaletteManager();
69+
6970
typedef enum {
7071
VERTEX_C,
7172
VERTEX_CN,

src/osgPlugins/dae/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
99
STRING(REGEX REPLACE "-Wextra" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
1010
ENDIF()
1111

12+
IF(CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
13+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
14+
ENDIF()
15+
1216

1317
SET(TARGET_SRC
1418
daeReader.cpp

src/osgPlugins/dae/ReaderWriterDAE.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232

3333
#define SERIALIZER() OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex)
3434

35+
#if __cplusplus > 199711L
36+
#define smart_ptr std::unique_ptr
37+
#else
38+
#define smart_prt std::auto_ptr
39+
#endif
3540

3641
osgDB::ReaderWriter::ReadResult
3742
ReaderWriterDAE::readNode(std::istream& fin,
@@ -73,7 +78,7 @@ ReaderWriterDAE::readNode(std::istream& fin,
7378
#endif
7479
}
7580

76-
std::auto_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit
81+
smart_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit
7782

7883
osgDAE::daeReader daeReader(pDAE, &pluginOptions);
7984

@@ -150,7 +155,8 @@ ReaderWriterDAE::readNode(const std::string& fname,
150155
pDAE = new DAE;
151156
#endif
152157
}
153-
std::auto_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit
158+
159+
smart_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit
154160

155161
osgDAE::daeReader daeReader(pDAE, &pluginOptions);
156162

@@ -247,7 +253,7 @@ ReaderWriterDAE::writeNode( const osg::Node& node,
247253
pDAE = new DAE;
248254
#endif
249255
}
250-
std::auto_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit
256+
smart_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit
251257

252258
// Convert file name to URI
253259
std::string fileURI = ConvertFilePathToColladaCompatibleURI(fname);

src/osgPlugins/stl/ReaderWriterSTL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class ReaderWriterSTL : public osgDB::ReaderWriter
113113
virtual WriteResult writeNode(const osg::Node& node, const std::string& fileName, const Options* = NULL) const;
114114

115115
private:
116-
class ReaderObject
116+
class ReaderObject : public osg::Referenced
117117
{
118118
public:
119119
ReaderObject(bool noTriStripPolygons, bool generateNormals = true):
@@ -526,7 +526,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterSTL::readNode(const std::string& fil
526526
else
527527
readerObject = new AsciiReaderObject(localOptions.noTriStripPolygons);
528528

529-
std::auto_ptr<ReaderObject> readerPtr(readerObject);
529+
osg::ref_ptr<ReaderObject> readerPtr(readerObject);
530530

531531
while (1)
532532
{

0 commit comments

Comments
 (0)