[osg-users] using ref_ptr in any case

Sebastian Schmidt herrdersuppen at gmail.com
Mon Mar 20 08:14:51 PDT 2017

robertosfield wrote:
> 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.

Thanks. I would like to stick to multi threading.
Even if it doesnt make sense in local scope i have a consitent way of using ref_ptr everytime.

Read this topic online here:

More information about the osg-users mailing list