Vincent,
I endorse what Peter said. The most important thing to remember with
ref_ptr is that each ref_ptr gets its own pointer to the object. If you
want to remove the original reference you must pass the ref_ptr by
reference (using the & in the calling sequence) and modify it directly.
-Eric
Peter Hrenka wrote:
Hi Vincent,
Vincent Bourdier schrieb:
Hi all,
I'm making some function to modify graph after some operation, and so
I need to call some simple actions in functions.
The problem is about ref_ptr :
I need to do this :
osg::ref_ptr<osg::Group> mygroup;
[..]
mygroup = NULL;
[...]
To do that in a function, I use someting like :
addonstack(mygroup, NULL); //prototype is :
addonstack(osg::ref_ptr<osg::Group> caller, osg::Node* arg1);
which did this :
osg::ref_ptr<osg::Node> nd = dynamic_cast<osg::Node*>(caller.get());
if(nd.get()){
nd =arg1;
But, the problem is that it doesn't change anything... I need, without
making some modifications in the addonstack prototype, a way to put
the ref_ptr to NULL .
Any idea ?
Thanks.
The addonstack function gets its own copy of the ref_ptr,
so it cannot modify the original ref_ptr.
To change the original ref_ptr you must change the signature to
addonstack(osg::ref_ptr<osg::Group>& caller, osg::Node* arg1);
But the code above (with the ref_ptr called "nd") will still not
work, since this is yet another copy of caller. You use the
reference "caller" directly, e.g.
caller = arg1;
Regards,
Vincent.
Hope this helps
Peter
------------------------------------------------------------------------
_______________________________________________
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