Added handling of when a View isn't yet assigned to a Viewer to avoid associated crash

This commit is contained in:
Robert Osfield
2009-01-07 14:49:04 +00:00
parent 536384457a
commit b1559ce696
2 changed files with 16 additions and 1 deletions

View File

@@ -119,6 +119,8 @@ bool CompositeViewer::readConfiguration(const std::string& filename)
void CompositeViewer::addView(osgViewer::View* view)
{
if (!view) return;
bool alreadyRealized = isRealized();
bool threadsWereRuinning = _threadsRunning;
@@ -128,6 +130,18 @@ void CompositeViewer::addView(osgViewer::View* view)
view->_viewerBase = this;
if (view->getSceneData())
{
// make sure that existing scene graph objects are allocated with thread safe ref/unref
if (getThreadingModel()!=ViewerBase::SingleThreaded)
{
view->getSceneData()->setThreadSafeRefUnref(true);
}
// update the scene graph so that it has enough GL object buffer memory for the graphics contexts that will be using it.
view->getSceneData()->resizeGLObjectBuffers(osg::DisplaySettings::instance()->getMaxNumberOfGraphicsContexts());
}
view->setFrameStamp(_frameStamp.get());
if (alreadyRealized)

View File

@@ -278,7 +278,8 @@ void View::setSceneData(osg::Node* node)
getSceneData()->accept(sodv);
// make sure that existing scene graph objects are allocated with thread safe ref/unref
if (getViewerBase()->getThreadingModel()!=ViewerBase::SingleThreaded)
if (getViewerBase() &&
getViewerBase()->getThreadingModel()!=ViewerBase::SingleThreaded)
{
getSceneData()->setThreadSafeRefUnref(true);
}