Paul Martz <[EMAIL PROTECTED]> wrote:
>
> >No, that's totally wrong. The originator of an object
> > must be the first to encapsulate an object in ref_ptr.
> >
>You're mistaken, my friend. An application can write code that
>allocates
>something derived from Referenced, but doesn't store it in a ref_ptr;
>instead the app passes it to OSG and OSG is then the first to assign a
>ref_ptr to it. The app has now relinquished control of that memory.
Good point which goes back to the problem of object ownership
and deletion responsibility.
The first class is buggy -- right?
The second class is correct -- right?
Thanks
-- Nathan
class App
{
App()
{
mGeom = new osg::Geometry;
group->addChild( mGeom ); // -- INVALIDATES mGeom ??? --
}
Func()
{
mGeom->setVertexArray(); // -- BUG! TOUCHED INVALIDATED MEMBER --
}
osg::Geometry* mGeom;
};
class App
{
App()
{
mGeom = new osg::Geometry;
group->addChild( mGeom.get() ); // get() for ret_ptr
}
Func()
{
mGeom->setVertexArray(); // ok -- mGeom still exists because refcnt > 0
}
ref_ptr<osg::Geometry> mGeom; // ref_ptr
};
---------------------------------
Get your own web address.
Have a HUGE year through Yahoo! Small Business._______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/