Hi Cory,

I've now done a review and believe I understand the motive behind
resetting the GraphicsThread point to 0 to delete the GraphicsThread,
this will co-operatively stop this thread safely, and allow the proper
clean of that graphics context.  However, I am concerned that this
will only work safely for single window applications, for
multi-context applications there can be a set of threads running in
the viewer, if we un-laterally destroy one of the threads then we
introduce the possibility of other threads hanging on barriers that no
longer have enough threads joining them to release them.

In the situation of multiple window app having one of it's windows
destroyed I believe the correct solution is probably to call
stopThreading() on the viewer so that all threads get a chance to be
released from any shared barriers and safely stopped.   I'm not yet
clear on exactly how we should best go from GraphicsWindowWin32 to any
associated viewers, but it'd probably be via the Camera's that have a
pointer to the View that owns them, and the osgViewer::View has a
pointer to the ViewerBase, that is either the CompositeViewer or
Viewer.   This is only required when there is a graphics thread on the
GraphicsWindow.

So peuso code might something like:


GraphicsWindow::destroyWindow(..)
{

..

if (_graphicsThread && _graphicsThread->isRunning())
{
     // find all the viewers that might own use this graphics context
     for(each camera on this GraphicsContext)
     {
           osgViewer::View* view =
dynamic_cast<osgViewer::View*>(camera->getView());
           osgViewer::ViewerBase* viewerBase = view ? view->getViewerBase() : 0;
           if (viewerBase && viewerBase->areThreadsRunning())
viewerBase->stopThreading();
     }

}

...
}


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

Reply via email to