Aaaaah ...
It's so obvious! Decades of programming is no guarantee for error free code.

Thanks!!!

On Wed, 26 Jan 2011 13:39:55 -0500, Jean-Sébastien Guay wrote:
Hello Werner, D.J.,

I would recommend that you either: 1)
use ref_ptr as your return type, or 2) wait to use ref_ptr outside of
"createObject".

Or return obj1.release() instead of obj1.get().

This tells the ref_ptr to decrease its ref count, but not delete the
object if it gets to 0 (contrary to get()). Which is what will happen
in your case (check with a debugger).

Incidentally, using a debugger would also have told you why it
crashes... checking the pointer after the call to your function would
have shown you that it had been deleted.

J-S

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to