Hi Sebastian, Using ref_ptr<> in local scope to objects t that are owned by external scope is a good practice but isn't always required.
If your application is multi-threaded then the external scope could unref and objects that you are using, so if you don't have your own reference to it it would go out of scope and you'd end up with a dangling pointer in your local scope. If your application is single threaded then it should be safe to just use C pointers in local scope while the object is kept alive by the external scope. Robert. On 20 March 2017 at 13:41, Sebastian Schmidt <[email protected]> wrote: > Hi. > I try to avoid possible memory leaks and currently replacing all pointers of > osg object types with ref_ptr. > > I read the osgproducer article and some other threads about these reference > pointers, but i wonder if there is any advantage for using ref_ptr also in > local scope as temporary references to existing pointers. > > > Code: > osg::ref_ptr<osgViewer::View> pView = dynamic_cast<osgViewer::View*>(&aa); > > [/code] > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=70512#70512 > > > > > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

