Hello,

While trying to create my custom serializer class, i created some dummy data 
which accidentally popped-up bug in InputStream readObjectFields function.

Bug description:
 Let's say we have class A
namespace Bug
{
class A : public osg::Object
{
public:
   //...
   typedef std::vector<osg::ref_ptr<A> > AList;

protected:
   AList _alist;
   //...
}
}

REGISTER_OBJECT_WRAPPER( A,
                         new Bug::A,
                         Bug::A,
                         "osg::Object Bug::A" )
{ 
        ADD_LIST_SERIALIZER(A,Bug::A::AList);
}


Bug:
We create say 3 instances of class A: A1,A2,A3 and then we add A2 and A3 and A1 
as child instances of A1 so we get next structure:
A1
 |- A2,A3,A1

we call osgDB::writeObjectFile(A1,"/data/a.osgt") -> saved correctly( third 
element in list is saved as unique id that references parentClass

now we call
A1 = osgDB::readObjectFile("/data/a.osgt");

Everything is deserialized correctely except last element in list which should 
be same instance as parent A1.

The attached code resolves this issue by passing UniqueID in readObjectFields 
method and saving object in _identifierMap as soon as we have valid object 
instance so we can make reference to parent object from any child instance.

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=45621#45621




Attachments: 
http://forum.openscenegraph.org//files/openscenegraph_708.zip


_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to