Hi Ulrich,

On 7 March 2014 19:46, Ulrich Hertlein <[email protected]> wrote:

> Yes, that was my understanding too.
> I was just advocating this procedure since it's sort of most-common
> practice in OSG to
> return raw pointers and the question came up.
>

Returning raw pointers is for efficiency and flexibility.  This case
shouldn't run into threading problems as the either the object has just
been created and put on the heap by the thread calling the method, or the
object that is returning the raw pointer has retained a ref_ptr<> to it.

It's what you do with the raw pointer next is what will make it thread-safe
or memory safe - if you go an just use a global C pointer for the object
during the rest of the life of the application you are going to see lots of
problems with leaks and dangling pointers, however, if you just use the C
pointer temporarily in local scope it should usually be safe.

My intention with the OSG is that it should provide basic mechanism to make
things robust, but not to become a nanny API where every possible misuse is
functionality has awkward mechanisms to prevent it.  The focus of the OSG
is about making it possible to use a power users, high performance scene
graph,

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

Reply via email to