does every osg::ref_ptr member of a class need been NULL in the destruction function?

classic Classic list List threaded Threaded
2 messages Options
LvQing LvQing
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

does every osg::ref_ptr member of a class need been NULL in the destruction function?

I am a little confuse about how to release an osg::ref_ptr member of a class.

for example,

Class A has a member of osg::ref_ptr<osg::Group> group & osg::ref_ptr<osg::Node> node

In the Class A's  construction :

                          group = new osg::Group().

                          node = new osg::Node().

                          group->addChild(node.get())

So the question is ,in class A's destruciton:

                         group->removeChild(node.get())

is it enough to release group  and node ? Need set group  = NULL & node =NULL;
             
                         THX!



gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: does every osg::ref_ptr member of a class need been NULL in the destruction function?

osg::ref_ptr deletes its referenced object when it goes out of scope (in this case, in the destructor) and the reference count goes to zero. So in your case, you don't need to do anything.
Glenn Waldron / Pelican Mapping
Loading...