Hi Robert

Your crash is down to retaining a c pointer to an object that has been
deleted. This dangling pointer issue is exactly why smart pointers are used
in modern C++ application.

Lots has been written about ref_ptr usage here over the years, as well as
docs and osg books that discuss it. So please do some of some background
reading.

In your own app you will either replace the c pointer usage with either a
ref_ptr or observer_ptr.

Robert

On 22 Jul 2014 19:50, "Robert Gosztyla" <robert.goszt...@gmail.com> wrote:
>
> Hi,
>
> Ok, i was mislead by previous thread and setting NULL to ref_ptr. So, i'm
using removeChild, as it should be and got crash. I'm doing this in such
way:
>
>
> Code:
>
> osg::ref_ptr < osg::Geode >  geode = new osg::Geode; // on start
> osg::Geode* g = geode.get(); // store pointer to my geode somewhere to
process my system
> myObject.storePointer(g);
>
> //and then (another method to delete node)
> osg::Geode* g = myObject.getPointer();
> osg::Group* gr = g->getParent(0); // there is no multiple parents
available
>
> gr->removeChild(g);
>
>
>
> Node 'g' seems to be removed from the scene, but then i've got a crash
(after leaving method to delete). I've commented out removing child and
there is no crash. And cannot find cause of that. Is it right way to do
such kind of operation as removing node from scene?
>
> Thank you!
>
> Cheers,
> Robert
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=60400#60400
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to