From 31592d206bfe761e65bf81c9f335a81667ee868d Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 27 May 2016 09:47:07 +0100 Subject: [PATCH] Changed the RenderStageCache::RenderStageMap to use map> in place of map> to avoid problems of dynamic_cast<> on an object that is being deleted. --- src/osgUtil/CullVisitor.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp index d198b7843..3112cdf2c 100644 --- a/src/osgUtil/CullVisitor.cpp +++ b/src/osgUtil/CullVisitor.cpp @@ -1368,7 +1368,7 @@ class RenderStageCache : public osg::Object, public osg::Observer { public: - typedef std::map > RenderStageMap; + typedef std::map > RenderStageMap; RenderStageCache() {} RenderStageCache(const RenderStageCache&, const osg::CopyOp&) {} @@ -1387,18 +1387,17 @@ class RenderStageCache : public osg::Object, public osg::Observer virtual void objectDeleted(void* object) { osg::Referenced* ref = reinterpret_cast(object); - osgUtil::CullVisitor* cv = dynamic_cast(ref); OpenThreads::ScopedLock lock(_mutex); - RenderStageMap::iterator itr = _renderStageMap.find(cv); + RenderStageMap::iterator itr = _renderStageMap.find(ref); if (itr!=_renderStageMap.end()) { _renderStageMap.erase(itr); } } - void setRenderStage(CullVisitor* cv, RenderStage* rs) + void setRenderStage(osg::Referenced* cv, RenderStage* rs) { OpenThreads::ScopedLock lock(_mutex); RenderStageMap::iterator itr = _renderStageMap.find(cv); @@ -1414,7 +1413,7 @@ class RenderStageCache : public osg::Object, public osg::Observer } - RenderStage* getRenderStage(osgUtil::CullVisitor* cv) + RenderStage* getRenderStage(osg::Referenced* cv) { OpenThreads::ScopedLock lock(_mutex); RenderStageMap::iterator itr = _renderStageMap.find(cv);