Just stick a .get() after the ref_ptr<> to get the C* and this will work just fine with removeChild.
On 7/19/06, N. Farr <[EMAIL PROTECTED]> wrote:
Bear with me guys, I'm just starting to feel my way around OSG/C++. I did what Robert suggested and went from osg::Group* to osg::ref_ptr<osg::Group>* and a buncha polymorphic type errors came up that to fix I changed my toolTrans from a PAT* to an osg::ref_ptr<osg::PositionAttitudeTransform>*. Now I can no longer use ->replaceChild(). Where do I go from here? Thanks. >From: "Robert Osfield" <[EMAIL PROTECTED]> >Reply-To: osg users <[email protected]> >To: "osg users" <[email protected]> >Subject: Re: [osg-users] Problem with >PositionAttitudeTransform'sreplaceChild() >Date: Wed, 19 Jul 2006 19:29:21 +0100 > >Are you using ref_pr<Node> for pointers to the Groups your are >managing? If not there is you problem. > >On 7/19/06, N. Farr <[EMAIL PROTECTED]> wrote: >>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/ >> >_______________________________________________ >osg-users mailing list >[email protected] >http://openscenegraph.net/mailman/listinfo/osg-users >http://www.openscenegraph.org/ _________________________________________________________________ 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/
_______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
