Hi Norm,

root->addDrawable (shape1); and root->addDrawable(shape1.get ()); are equivalent. The bare shape1 argument will be implicitly converted to Drawable *.

http://trac.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00319.html

The osg::Referenced objects store their own reference count (intrusive reference counting), unlike std::shared_ptr where the reference counts are stored with the smart pointer.

i.e., root->addDrawable (new ShapeDrawable ()); will not result in a memory leak either.

Regards,

Judson

On 7/23/2014 2:44 PM, Norm Goldstein wrote:
Hi,
In the excellent Beginners Guide, there is this code snippet (page 64):

Code:
osg::ref_ptr < osg::ShapeDrawable > shape1 = new osg::ShapeDrawable;
osg::ref_ptr < osg::Geode > root = new osg::Geode;
root->addDrawable( shape1.get() );



However, I would think the last line should be

Code:
root->addDrawable( shape1 );


to properly manage the memory.
??
Thank you!

Cheers,
Norm
PS I had to put spaces around the angle brackets.  Otherwise, they would not 
appear in the post.

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





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to