On 18.10.2013 18:39, Robert Osfield wrote:
One thing I don't understand yet is why you call reset() then set the
_state pointer to null.  Is it that there is another reference to the State
object that _state points to prevent the  _state = 0 from deleting the
object?
Yes I think so, but I'm not sure. The reset was there even before my changes and I can only assume that the reason was to derefernce _state.

The whole point of this patch is to ensure the State is destroyed before the call to osg::deleteAllGLObjects(contextID):

            if ( !sharedContextExists )
            {
                OSG_INFO<<"Doing delete of GL objects"<<std::endl;
                _state->reset();
                _state = 0;
                osg::deleteAllGLObjects(contextID);
                OSG_INFO<<"Done delete of GL objects"<<std::endl;
            }

However, there is still a possibility that the user code is holding count to the _state and _state will not be deleted. That being said, it might be a good idea to issue a warning, something like:

            if ( !sharedContextExists )
            {
                OSG_INFO<<"Doing delete of GL objects"<<std::endl;
                _state->reset();
                if (_state->referenceCount() > 1)
                {
OSG_WARN<<"GraphicsContext::close(): Some of the GL objects might not be deleted."<<std::endl;
                }
                _state = 0;
                osg::deleteAllGLObjects(contextID);
                OSG_INFO<<"Done delete of GL objects"<<std::endl;
            }


BTW, it is usually not a problem when GL objects with an not-in-use id gets deleted at the wrong context, but the object id might as well be a valid one and the object (the display list, program ...) gets unexpectedly wiped out of the existence.

Best Regards
Robert Milharcic

_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to