Hi all

in the body of class osgViewer::View, EventHandlers is defined as follows:

    typedef std::list< osg::ref_ptr<osgGA::GUIEventHandler> > EventHandlers;
    
In fact, I use a wrapper class for OSG in my application which acts as a
container for all major OSG objects, like Viewer, Manipulator, etc.
This class also acts as a event handler, so adds itself to the list of event 
handlers, and here comes the problem.
Since my wrapper class uses a ref_ptr to hold the address of Viewer and viewer 
holds my wrapper's address in the list of 
event handlers using a ref_ptr too, we have a chain which resides in memory 
forever.
But, if we define EventHandlers as a list of observer pointers, there will be 
no problem and anything becomes deleted correctly.
Also, there is no such removeEventHandler function in View class, which I think 
could help me to solve the problem.

Now, I use getEventHandlers function and call the clear function to remove all 
event handlers when I receive the done signal.
But as mentioned before, I think it would be better to define EventHandlers as 
a list observer pointers, unless I have missed something special.

So is there any specific reason for using ref_ptr instead of observer_ptr in 
definition of osgViewer::View::EventHandlers?

Regards, Moji the Great




      
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to