Hi Randy,

I don't know a problem with replaceChild, its rather well established
and tested code.

Crashes like this would typically be due to lack of ref counting of
global pointers to nodes in  the scene graph.  I note you're using
ref_ptr<> in some places, not in others.

Robert.

On 4/10/07, Neatrour, Randall <[EMAIL PROTECTED]> wrote:




I assume there is no issue with the method virtual bool replaceChild (Node
*origChild, Node *newChild).   For some reason, this code core dumps
somewhere in the depths of replaceChild, or I think it does.   The code adds
and deletes, but crashes when I try to update something already in the
group.  Any ideas what I am doing wrong?



osg::ref_ptr<osg::Geode> g[10];

osg::ref_ptr<osg::Geode> tmp;



void drawTrack::deleteTrk(int trk_list[], int num_del)

{

   int i = 0;

   trck d;

   osg::Group* group = PPIViewport::getGroup();

   osgProducer::Viewer* viewer = PPIViewport::getViewer();



   while(i < num_del)

   {

      group->removeChild(g[trk_list[i]].get());

      viewer->requestRedraw();

      i++;

   }

}



void drawTrack::drawTrk(TrkMdl** t)

{

   int i = 0;

   const float OFFSET = .005;

   trck d;

   osg::Group* group = PPIViewport::getGroup();

   osgProducer::Viewer* viewer = PPIViewport::getViewer();





   while(t[i] != NULL)

   {

       if(group->containsNode(g[i].get()))

       {

         tmp = d.draw((t[i]->latitude * OFFSET), (t[i]->longitude * OFFSET),
t[i]->track_id);

         group->replaceChild(g[i].get(), tmp.get());

         g[i] = tmp;

       }

       else

       {

         g[i] = d.draw((t[i]->latitude * OFFSET), (t[i]->longitude *
OFFSET), t[i]->track_id);

         group->addChild(g[i].get());

       }

       i++;

   }

}



Thanks,

Randy Neatrour
_______________________________________________
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/

Reply via email to