[osg-users] CullVisitor object not getting properly deleted

Julien Valentin julienvalentin51 at gmail.com
Mon May 23 10:07:29 PDT 2016


Hi
Your problem is weird, further I don't understand why you would have to create yourself a cullvisitor...
Give us the minimum code to reproduce the error please
(and use code section to keep indentation)


Rick Irons wrote:
> Hi all, 
> 
> I am encountering an issue with a CullVisitor object not being properly deleted in version 3.4.0. I am encountering this issue when updating from version 3.0.1. 
> 
> The source of the problem is a failed Referenced to CullVisitor dynamic cast that occurs in the code below… 
> 
> 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(cv); 
> } 
> } 
> 
> The call stack at the time of the failed cast is the following… 
> 
> 
> 
> The cv pointer is NULL following the cast. My suspicion is that the dynamic cast is failing because we are in the destructor of our own object that inherits the OSG CullVisitor object. I tested this suspicion by confirming that the same dynamic cast will succeed in application code if done immediately before invoking the destructor of our version of the CullVisitor. This issue is blocking our update to 3.4.0 since it causes numerous unit test failures. 
> 
> Any suggestions on how to address this issue?  
> 
> I created the hack below to temporary bypass the problem… 
> 
> 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); 
> if (cv != NULL) 
> { 
> RenderStageMap::iterator itr = _renderStageMap.find(cv); 
> if (itr!=_renderStageMap.end()) 
> { 
> _renderStageMap.erase(cv); 
> } 
> } 
> else 
> { 
> for(RenderStageMap::iterator itr = _renderStageMap.begin(); 
> itr != _renderStageMap.end(); 
> ++itr) 
> { 
> osg::Referenced* tmpRef = dynamic_cast<osg::Referenced*>(itr->first); 
> if (ref==tmpRef) 
> { 
> cv = itr->first; 
> _renderStageMap.erase(cv); 
> break; 
> } 
> } 
> } 
> } 
> 
> Thanks, 
> Rick
> 
>  ------------------
> Post generated by Mail2Forum


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








More information about the osg-users mailing list