Hello all,

I have a number of pointers to several osg::Groups that I am making children of a PositionAttitudeTransform by using replaceChild on the PAT. It works fine until I try to go back to the Group that started out as the initial child of the PAT, in which case the program crashes with a memory violation. Right now, I have to recreate the osg::Groups (actually pointers to osg::Groups) from scratch, and because I cann't delete a pointer to an osg::Group (error C2248: 'osg::Group::Group' : cannot access protected member declared in class 'osg::Group') I have a memory leak. Any ideas how to get replaceChild not to crash? Is there another way of doing this?

Here's my code:
//All tools are osg::Group* and toolTrans is a PAT*
if (currentTool == tool1) nextTool = tool2;
else if (currentTool == tool2) nextTool = tool3;
else if (currentTool == tool3) nextTool = tool4;
else if (currentTool == tool4) nextTool = tool1;
toolTrans->replaceChild(dynamic_cast<osg::Node*> (currentTool), dynamic_cast<osg::Node*> (nextTool)); //CRASHES HERE ONLY WHEN GOING FROM tool4 to tool1.
currentTool = nextTool;

Thanks all.

_________________________________________________________________
Play Q6 for your chance to WIN great prizes. http://q6trivia.imagine-live.com/enca/landing

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to