[osg-users] Problems shutting down Composite Viewer/View/Custom drawables

Cole, Charles E. (LARC-B702)[RAYTHEON TECHNICAL SERVICES COMPANY] charles.e.cole at nasa.gov
Mon Mar 30 05:33:43 PDT 2009


Hi J-S,

> One thing you need to be careful of when deriving classes from OSG base
> classes which themselves derive from osg::Referenced ... In most cases,
> the destructors of those classes should be protected. Since they're
> normally protected already (as in osg::Object, osg::Drawable, etc) you
> shouldn't expose them in public scope in your derived class, which
> would
> allow them to be (erroneously) deleted at any time by the application
> instead of being deleted automatically when their ref count goes down
> to 0.

That was the problem.  The destructor of my derived class was public.  I changed it to protected and to use a ref_ptr for the class and no more crashes.  I'm not sure I would have ever found this bug.  I wasn't even looking in that direction.  So, thanks so much!

chuck
 



More information about the osg-users mailing list