Added handling of when a View isn't yet assigned to a Viewer to avoid associated crash
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user