Hi Robert I understand the point but the Gents example was not using a Ref pointer, hence the way I replied :)
But I would also argue that theres nothing wrong in using unref() if you know what the life cycle of your object is. Best Regards Gordon __________________________________________________________ "Self defence is not a function of learning tricks but is a function of how quickly and intensely one can arouse one's instinct for survival" - Master Tambo Tetsura -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Robert Osfield Sent: Wednesday, November 22, 2006 4:22 PM To: osg users Subject: Re: [osg-users] delete osg::Vec3Array Hi Gordon, On 11/22/06, Gordon Tomlinson <[EMAIL PROTECTED]> wrote: > base_vertices->unref() which will decrement the reference count which when > it reaches zero will self delete Argghgh, I strongly recommend against using unref() to force deletion, as it could easily break references held to the OSG object. Only use ref() and unref() in exceptional circumstances and when you no exactly what the consequences are. This equates to about 0.00000001% of usage of reference counted objects. The solution is to use ref_ptr<> entirely, it'll automatically ensure that everything is cleaned up, and done so safe, even in the presence of exeptions. { osg::ref_ptr<osg::Vec3Array> base_vertices = new osg::Vec3Array(NumberOfVertexInBox); // ref_ptr constructs increments ref count by 1 to 1. // do stuff } // ref_ptr<> destructs, calls unref to decrement ref count be 1, if no other additional references have been take than the object will automatically be deleted. Robert. Robert. _______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/ _______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
