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) {