From e7d41377be1e6ebc3c4117c3c4eef6826a91f1ef Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 25 Feb 2015 14:55:59 +0000 Subject: [PATCH] Fixed handling of NULL entries in osg::Geometry TexCoordArrayList and VertexAttribArrayList. git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14715 16af8721-9629-0410-8352-f15c8da7e697 --- include/osgDB/Serializer | 5 ++++- src/osgDB/InputStream.cpp | 9 ++++++++- src/osgDB/OutputStream.cpp | 6 +++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/include/osgDB/Serializer b/include/osgDB/Serializer index 2906c0bea..e524fbd22 100644 --- a/include/osgDB/Serializer +++ b/include/osgDB/Serializer @@ -585,7 +585,10 @@ public: if ( os.isBinary() ) { os << hasObject; - os.writeObject( value ); + if (hasObject) + { + os.writeObject( value ); + } } else if ( ParentType::_defaultValue!=value ) { diff --git a/src/osgDB/InputStream.cpp b/src/osgDB/InputStream.cpp index cb6b5c62f..d4b5e5237 100644 --- a/src/osgDB/InputStream.cpp +++ b/src/osgDB/InputStream.cpp @@ -815,7 +815,14 @@ osg::Object* InputStream::readObject( osg::Object* existingObj ) { std::string className; unsigned int id = 0; - *this >> className >> BEGIN_BRACKET >> PROPERTY("UniqueID") >> id; + *this >> className; + + if (className=="NULL") + { + return 0; + } + + *this >> BEGIN_BRACKET >> PROPERTY("UniqueID") >> id; if ( getException() ) return NULL; IdentifierMap::iterator itr = _identifierMap.find( id ); diff --git a/src/osgDB/OutputStream.cpp b/src/osgDB/OutputStream.cpp index c93fb0d10..12cfed7b2 100644 --- a/src/osgDB/OutputStream.cpp +++ b/src/osgDB/OutputStream.cpp @@ -577,7 +577,11 @@ void OutputStream::writeImage( const osg::Image* img ) void OutputStream::writeObject( const osg::Object* obj ) { - if ( !obj ) return; + if ( !obj ) + { + *this << std::string("NULL") << std::endl; // Write NULL token. + return; + } std::string name = obj->libraryName(); name += std::string("::") + obj->className();