From bedd22de23eedbdaab0502bb9ecbc464cfa25912 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 13 Jul 2009 16:39:51 +0000 Subject: [PATCH] From Cory Riddel based on suggestion from Robert Osfield, "I've been running with your suggested changes for a few days now and it has been working perfectly. I'm still not entirely clear why adding a slave/subgraph causes the problem." --- src/osgViewer/GraphicsWindowWin32.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/osgViewer/GraphicsWindowWin32.cpp b/src/osgViewer/GraphicsWindowWin32.cpp index d3684c801..2366bf071 100644 --- a/src/osgViewer/GraphicsWindowWin32.cpp +++ b/src/osgViewer/GraphicsWindowWin32.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -1270,6 +1271,21 @@ void GraphicsWindowWin32::destroyWindow( bool deleteNativeWindow ) { if (_destroying) return; _destroying = true; + + if (_graphicsThread && _graphicsThread->isRunning()) + { + // find all the viewers that might own use this graphics context + osg::GraphicsContext::Cameras cameras = getCameras(); + for(osg::GraphicsContext::Cameras::iterator it=cameras.begin(); it!=cameras.end(); ++it) + { + osgViewer::View* view = dynamic_cast((*it)->getView()); + osgViewer::ViewerBase* viewerBase = view ? view->getViewerBase() : 0; + if (viewerBase && viewerBase->areThreadsRunning()) + { + viewerBase->stopThreading(); + } + } + } if (_hdc) {