diff --git a/include/osgDB/InputStream b/include/osgDB/InputStream index af431f46c..cf0999815 100644 --- a/include/osgDB/InputStream +++ b/include/osgDB/InputStream @@ -138,7 +138,7 @@ public: osg::PrimitiveSet* readPrimitiveSet(); osg::Image* readImage(bool readFromExternal=true); osg::Object* readObject( osg::Object* existingObj=0 ); - osg::Object* readObjectFields( const std::string& className, osg::Object* existingObj=0); + osg::Object* readObjectFields( const std::string& className, unsigned int id, osg::Object* existingObj=0); /// set an input iterator, used directly when not using InputStream with a traditional file releated stream. void setInputIterator( InputIterator* ii ) { _in = ii; } diff --git a/src/osgDB/InputStream.cpp b/src/osgDB/InputStream.cpp index a86820bfe..47ed5ba64 100644 --- a/src/osgDB/InputStream.cpp +++ b/src/osgDB/InputStream.cpp @@ -599,9 +599,7 @@ osg::Image* InputStream::readImage(bool readFromExternal) image->setWriteHint( (osg::Image::WriteHint)writeHint ); } - image = static_cast( readObjectFields(className, image.get()) ); - - _identifierMap[id] = image; + image = static_cast( readObjectFields(className, id, image.get()) ); return image.release(); } @@ -620,16 +618,14 @@ osg::Object* InputStream::readObject( osg::Object* existingObj ) return itr->second.get(); } - osg::ref_ptr obj = readObjectFields( className, existingObj ); - - _identifierMap[id] = obj; + osg::ref_ptr obj = readObjectFields( className, id, existingObj ); advanceToCurrentEndBracket(); return obj.release(); } -osg::Object* InputStream::readObjectFields( const std::string& className, osg::Object* existingObj ) +osg::Object* InputStream::readObjectFields( const std::string& className, unsigned int id, osg::Object* existingObj ) { ObjectWrapper* wrapper = Registry::instance()->getObjectWrapperManager()->findWrapper( className ); if ( !wrapper ) @@ -641,6 +637,7 @@ osg::Object* InputStream::readObjectFields( const std::string& className, osg::O _fields.push_back( className ); osg::ref_ptr obj = existingObj ? existingObj : wrapper->getProto()->cloneType(); + _identifierMap[id] = obj; if ( obj.valid() ) { const StringList& associates = wrapper->getAssociates();