From 14805dc8b94549af460bdec788971503df54b89f Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 23 Jun 2016 07:47:40 +0100 Subject: [PATCH] Restructed setting of vertex array to avoid possible reference of null --- src/osgText/GlyphGeometry.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/osgText/GlyphGeometry.cpp b/src/osgText/GlyphGeometry.cpp index 5a08f0672..22d08f465 100644 --- a/src/osgText/GlyphGeometry.cpp +++ b/src/osgText/GlyphGeometry.cpp @@ -493,8 +493,12 @@ public: unsigned int start = (*_elements)[0]; unsigned int count = _elements->size(); - if (geometry->getVertexArray()==0) geometry->setVertexArray(new osg::Vec3Array(*_vertices)); osg::Vec3Array* new_vertices = dynamic_cast(geometry->getVertexArray()); + if (!new_vertices) + { + new_vertices = new osg::Vec3Array(*_vertices); + geometry->setVertexArray(new_vertices); + } // allocate the primitive set to store the face geometry osg::ref_ptr face = new osg::DrawElementsUShort(GL_POLYGON); @@ -1342,7 +1346,7 @@ OSGTEXT_EXPORT osg::Geometry* computeShellGeometry(osg::Geometry* glyphGeometry, osg::CopyOp copyop(osg::CopyOp::DEEP_COPY_ALL); - osg::DrawElementsUShort* front_strip = dynamic_cast(copyop(strip)); + osg::DrawElementsUShort* front_strip = new osg::DrawElementsUShort(*strip, copyop); text_geometry->addPrimitiveSet(front_strip); for(unsigned int i=0; isize(); ++i) { @@ -1362,7 +1366,7 @@ OSGTEXT_EXPORT osg::Geometry* computeShellGeometry(osg::Geometry* glyphGeometry, std::swap(p1,p2); } - osg::DrawElementsUShort* back_strip = dynamic_cast(copyop(strip)); + osg::DrawElementsUShort* back_strip = new osg::DrawElementsUShort(*strip, copyop); text_geometry->addPrimitiveSet(back_strip); for(unsigned int i=0; isize(); ++i) {