Show
Ignore:
Timestamp:
12/20/10 13:03:56 (4 years ago)
Author:
robert
Message:

Fixed memory leak by introducing use of ref_ptr<>

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osganimationmorph/osganimationmorph.cpp

    r12046 r12047  
    4949}; 
    5050 
    51 osg::Geometry* getShape(const std::string& name) 
     51osg::ref_ptr<osg::Geometry> getShape(const std::string& name) 
    5252{ 
    53     osg::Node* shape0 = osgDB::readNodeFile(name); 
    54     GeometryFinder finder; 
    55     /* 
    56     shape0->accept(finder); 
    57     return finder._geom.get(); 
    58     */ 
    59     //is changed to 
     53    osg::ref_ptr<osg::Node> shape0 = osgDB::readNodeFile(name); 
    6054    if (shape0) 
    6155    { 
     56        GeometryFinder finder; 
    6257        shape0->accept(finder); 
    63         return finder._geom.get(); 
     58        return finder._geom; 
    6459    } 
    6560    else 
     
    8984    bam->registerAnimation(animation); 
    9085 
    91     osg::Geometry* geom0 = getShape("morphtarget_shape0.osg"); 
     86    osg::ref_ptr<osg::Geometry> geom0 = getShape("morphtarget_shape0.osg"); 
    9287    if (!geom0) { 
    9388        std::cerr << "can't read morphtarget_shape0.osg" << std::endl; 
     
    9590    } 
    9691 
    97     osg::Geometry* geom1 = getShape("morphtarget_shape1.osg"); 
     92    osg::ref_ptr<osg::Geometry> geom1 = getShape("morphtarget_shape1.osg"); 
    9893    if (!geom1) { 
    9994        std::cerr << "can't read morphtarget_shape1.osg" << std::endl; 
     
    10398    // initialize with the first shape 
    10499    osgAnimation::MorphGeometry* morph = new osgAnimation::MorphGeometry(*geom0); 
    105     morph->addMorphTarget(geom1); 
     100    morph->addMorphTarget(geom1.get()); 
    106101 
    107102    viewer.setCameraManipulator(new osgGA::TrackballManipulator());