Hi Pjotr, Better late then never, change to using osg::observer_ptr<osg::Camera> now checked in to svn/trunk :-)
Cheers, Robert. On 4 March 2013 10:17, Pjotr Svetachov <[email protected]> wrote: > Hello Robert, > > Sorry for the delay, I have been on a holiday and also had some client > work. Your approach with the observer_ptr works great. > To make it compile I had to add .get() and .valid() in some places, > see the added code. > > Cheers, > Pjotr > > On 24 January 2013 11:43, Robert Osfield <[email protected]> wrote: >> Hi Pjotr, >> >> Comments below: >> >> On 8 January 2013 14:22, Pjotr Svetachov <[email protected]> wrote: >>> 2) Another rare crash in renderer in the >>> collateReferencesToDependentCameras or >>> clearReferencesToDependentCameras functions: if you set the nodemask >>> of the main or the slave camera to zero and then delete a >>> render-to-texture camera from the scene it could crash. It took me a >>> while to find out what the problem was because those two function are >>> there to prevent crashes on camera deletion in the first place. The >>> problem is that those two methods collect all the camera's from the >>> render stages. What happens is that when the node mask is zero the >>> cull stage is skipped and the render stages are not updated (or reset) >>> so in that case those two methods will work on outdated data which >>> includes outdated camera pointers. To fix this you can skip the >>> collecting of rtt camera references if the nodemask is zero as the >>> draw phase is skipped anyway. >> >> I've been looking at the >> SceneView::collateReferencesToDependentCameras() method which uses the >> RenderStage::collateReferencesToDependentCameras(), these methods >> outwardly look safe except for the potential for a dangling >> RenderStage::_camera pointer. While I haven't reproduced the problem >> you are trying to address this does look like a reasonable candidate >> for the cause of the crash. >> >> If this dangling RenderStage::_camera is the problem then using a >> osg::observer_ptr<> would be the solution. i.e in >> include/osgUtil/RenderStage header we'd change the >> >> osg::Camera* _camera; >> >> To: >> >> osg::observer_ptr<Camera> _camera; >> >> >> Could you try this out and see if it fixes the problem? If this >> fixes the problem then I'll merge this change. >> >> Robert. >> _______________________________________________ >> osg-submissions mailing list >> [email protected] >> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org > > _______________________________________________ > osg-submissions mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org > _______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
