Hi Rick, As general note, use of a C pointer to scene graph objects include the CullVisitor should generally be avoided, it's only safe for small blocks of code where you know that the objects will remain in memory at all times during the block. Instead you should use ref_ptr<> to make sure it's lifetime is correct - if in doubt use ref_ptr<>.
I will have a look at the use of dynamic_cast<> again. I had to keep it in there because the pointer to the Referenced base class isn't castable directly to a CullVsititor as CullVisitor uses virtual inheritance. Robert. On 26 May 2016 at 22:04, Rick Irons <rick.ir...@mathworks.com> wrote: > Hi Robert, > > > > Unfortunately the fix didn't address the crash I am encountering. The issue > of the dynamic cast in objectDeleted() > (\openscenegraph\src\osgUtil\CullVisitor.cpp) failing remains... > > > > virtual void objectDeleted(void* object) > > { > > osg::Referenced* ref = > reinterpret_cast<osg::Referenced*>(object); > > osgUtil::CullVisitor* cv = > dynamic_cast<osgUtil::CullVisitor*>(ref); > > > > OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex); > > > > RenderStageMap::iterator itr = _renderStageMap.find(cv); > > if (itr!=_renderStageMap.end()) > > { > > _renderStageMap.erase(itr); > > } > > } > > > > I was going to define our object that inherits from the CullVisitor as an > osg::ref_ptr. Perhaps doing so will delay the freeing of the CullVisitor > object long enough within the CullVisitor destructor so that the problematic > dynamic cast will succeed. I am open to any other suggestions as well. I > may have to resort to just creating a small example program that reproduces > the issue. > > > > Thanks, > > Rick > > > > -----Original Message----- > From: Rick Irons > Sent: Wednesday, May 25, 2016 5:56 AM > To: OpenSceneGraph Users <osg-users@lists.openscenegraph.org> > Subject: Re: [osg-users] CullVisitor object not getting properly deleted > > > > Hi Robert, > > > > Thanks for the update. I will try out the fix. > > > > Rick > > > >> On May 24, 2016, at 3:53 PM, Robert Osfield <robert.osfi...@gmail.com> >> wrote: > >> > >> Hi Rick, > >> > >> After a preplexing day looking at how the osgUtiil::CullVisitor, > >> osg::Camera and RenderStageCache were all interacting via the > >> osg::Observer system I finally fixed the problem with the crash that > >> I've see with the osgoit and osgprerender examples. As the crash > >> looks similar to what you saw there is reasonable chance that the > >> changes should work for you too. > >> > >> I have checked my fix into master and OpenSceneGraph-3.4. > >> > >> Robert. > >> _______________________________________________ > >> osg-users mailing list > >> osg-users@lists.openscenegraph.org > >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph. > >> org > > > _______________________________________________ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org