Vincent Bourdier a écrit :
In argument of my function, I get a ref_ptr, and in the function, I
put this ref_ptr to NULL;
but at the end (going out of the function), my original ref_ptr hasn't
been modified...
Do you pass your ref_ptr by value or by reference ?
Here is an example :
ref_ptr<osg::Node> g_node;
void bad(ref_ptr<osg::Node> ptr) {
ptr = 0;
}
void good(ref_ptr<osg::Node>& ptr) {
ptr = 0;
}
int main() {
ref_ptr<Node> node = new Node();
bad(node);
// Here node != 0
good(node)
// Here node ==0
return 0;
}
I don't know if it is more understandable, but it's not easy to explain...
Thanks for help.
Vincent.
2008/5/23 Robert Osfield <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>:
Hi Vincent,
I don't know if anyone else can make sense of what you are trying to
do, based on your email, but I'm just lost. I kinda doubt the problem
is really about ref_ptr<>, but something related to the overall code
that you have written, but since I can't really spot what you intend
or what might be going on I certainly can't help.
Robert.
On Fri, May 23, 2008 at 9:02 AM, Vincent Bourdier
<[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
wrote:
> 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.
>
> Regards,
> Vincent.
>
> _______________________________________________
> osg-users mailing list
> [email protected]
<mailto:[email protected]>
>
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
[email protected]
<mailto:[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
--
Lamoliatte Stephane
Ingenieur R&D
R.S.A. Cosmos
Z.I. de la Vaure - B.P.40
42290 Sorbiers, France
Tél : +33 (0)4 77 53 30 48
Fax : +33 (0)4 77 53 38 61
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org