[osg-users] Manual deleting nodes again...

2014-07-22 Thread Robert Gosztyla
Hi, Searching forum i've found such topic http://forum.openscenegraph.org/viewtopic.php?t=5758, which is quite similar to my problem, however does not solved my issue. I'm trying to write functionality to remove node with all subnodes, but cannot get it to work. Assign NULL to shared pointer (

Re: [osg-users] Manual deleting nodes again...

2014-07-22 Thread Robert Osfield
Hi Robert, The OSG automatically reference counts Nodes and other objects in the scene graph. If you want to remove Nodes or other objects from the scene graph you need to call the appropriate methods to removing them. If you want to remove a child from a group then you simply call group->remove

Re: [osg-users] Manual deleting nodes again...

2014-07-22 Thread Robert Gosztyla
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

Re: [osg-users] Manual deleting nodes again...

2014-07-22 Thread Robert Osfield
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