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/

Reply via email to