Hi,

I have used the osg::ref_ptr quite a lot and never had much problems with them, 
but I'm having an issue with it now.

In the main function I create a viewer (and also a DisplaySettings that is used 
by it):


Code:
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer();
osg::ref_ptr<osg::DisplaySettings> ds = new osg::DisplaySettings();
...
viewer->setDisplaySettings(ds);
...




then I also have a new class called RenderManager, who needs to viewer object 
as well. I thought this was the correct way to do it:


Code:
class RenderManager
{

    osg::ref_ptr<osgViewer::Viewer> viewer;
    ....
    osg::ref_ptr<osgViewer::Viewer> getViewer() { return viewer; } 
    RenderManager(osg::ref_ptr<osgViewer::Viewer> viewer);
}

RenderManager::RenderManager(osg::ref_ptr<osgViewer::Viewer>):
        viewer(viewer)
{
}



and I create one in main, and delete it at the end of main


Code:
RenderManager * renderManager = new RenderManager(viewer);
....
delete renderManager;




(I tried to simplify the code a.m.a.p.)

Now the delete seems to go well, but at the very end of main it will give a 
access violation in the destructor of ref_ptr:

        
world2.exe!osg::ref_ptr<osgViewer::Viewer>::~ref_ptr<osgViewer::Viewer>()  Line 
35 + 0x2e bytes C++

What did I do wrong? What is the correct way to do it? 


Thank you!

Cheers,
Bram

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=60258#60258





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to