From 7e4b41e41adbdf116df064b6412337e8e631af6d Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 19 Aug 2014 09:27:46 +0000 Subject: [PATCH] Fixed MD2 danglng pointer crash. git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14413 16af8721-9629-0410-8352-f15c8da7e697 --- src/osgPlugins/md2/ReaderWriterMD2.cpp | 32 +++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/osgPlugins/md2/ReaderWriterMD2.cpp b/src/osgPlugins/md2/ReaderWriterMD2.cpp index fe26e6bcb..c45e0149b 100644 --- a/src/osgPlugins/md2/ReaderWriterMD2.cpp +++ b/src/osgPlugins/md2/ReaderWriterMD2.cpp @@ -208,12 +208,12 @@ load_md2 (const char *filename, const osgDB::ReaderWriter::Options* options) // read in the frame info into a vector const char *last_frame_name = NULL; - osg::Vec3Array *vertexCoords = NULL; - osg::Vec2Array *texCoords = NULL; - osg::UIntArray *vertexIndices = NULL; - osg::UIntArray *texIndices = NULL; - osg::Vec3Array *normalCoords = NULL; - osg::UIntArray *normalIndices = NULL; + osg::ref_ptr vertexCoords = NULL; + osg::ref_ptr texCoords = NULL; + osg::ref_ptr vertexIndices = NULL; + osg::ref_ptr texIndices = NULL; + osg::ref_ptr normalCoords = NULL; + osg::ref_ptr normalIndices = NULL; // load the texture skins @@ -375,24 +375,24 @@ load_md2 (const char *filename, const osgDB::ReaderWriter::Options* options) } } - deprecated_osg::Geometry *geom = new deprecated_osg::Geometry; + osg::ref_ptr geom = new deprecated_osg::Geometry; - geom->setVertexArray (vertexCoords); - geom->setVertexIndices (vertexIndices); + geom->setVertexArray (vertexCoords.get()); + geom->setVertexIndices (vertexIndices.get()); - geom->setTexCoordArray (0, texCoords); - geom->setTexCoordIndices (0, texIndices); + geom->setTexCoordArray (0, texCoords.get()); + geom->setTexCoordIndices (0, texIndices.get()); - geom->setNormalArray (normalCoords); - geom->setNormalIndices (normalIndices); + geom->setNormalArray (normalCoords.get()); + geom->setNormalIndices (normalIndices.get()); geom->setNormalBinding (deprecated_osg::Geometry::BIND_PER_VERTEX); geom->addPrimitiveSet (new osg::DrawArrays (osg::PrimitiveSet::TRIANGLES, 0, vertexIndices->size ())); - osg::Geode *geode = new osg::Geode; - geode->addDrawable (geom); + osg::ref_ptr geode = new osg::Geode; + geode->addDrawable (geom.get()); - current_sequence->addChild (geode); + current_sequence->addChild (geode.get()); current_sequence->setTime (sequence_frame, 0.2f); sequence_frame++;