Made Refernced::setThreadSafeReferenceCounting(bool) a virtual then overrode
this in various scene graph classes to ensure that the scene graph gets updated as well as the objects that the initialial call is made from.
This commit is contained in:
@@ -585,6 +585,8 @@ void GraphicsWindowX11::closeImplementation()
|
||||
|
||||
XFlush( _display );
|
||||
XSync( _display,0 );
|
||||
|
||||
XCloseDisplay( _display );
|
||||
}
|
||||
|
||||
_window = 0;
|
||||
@@ -626,6 +628,7 @@ void GraphicsWindowX11::checkEvents()
|
||||
int windowWidth = _traits->width;
|
||||
int windowHeight = _traits->height;
|
||||
|
||||
bool destroyWindowRequested = false;
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"Check events"<<std::endl;
|
||||
while( XPending(_display) )
|
||||
@@ -640,7 +643,7 @@ void GraphicsWindowX11::checkEvents()
|
||||
if (static_cast<Atom>(ev.xclient.data.l[0]) == _deleteWindow)
|
||||
{
|
||||
osg::notify(osg::INFO)<<"DeleteWindow event recieved"<<std::endl;
|
||||
close();
|
||||
destroyWindowRequested = true;
|
||||
}
|
||||
}
|
||||
case Expose :
|
||||
@@ -842,6 +845,12 @@ void GraphicsWindowX11::checkEvents()
|
||||
resized(windowX, windowY, windowWidth, windowHeight);
|
||||
getEventQueue()->windowResize(windowX, windowY, windowWidth, windowHeight);
|
||||
}
|
||||
|
||||
if (destroyWindowRequested)
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GraphicsWindowX11::grabFocus()
|
||||
|
||||
@@ -22,7 +22,11 @@ using namespace osgViewer;
|
||||
View::View()
|
||||
{
|
||||
// osg::notify(osg::NOTICE)<<"Constructing osgViewer::View"<<std::endl;
|
||||
setEventQueue(new osgGA::EventQueue);
|
||||
|
||||
// make sure View is safe to reference multi-threaded.
|
||||
setThreadSafeRefUnref(true);
|
||||
|
||||
setEventQueue(new osgGA::EventQueue);
|
||||
}
|
||||
|
||||
View::~View()
|
||||
|
||||
@@ -158,7 +158,19 @@ void Viewer::startThreading()
|
||||
stopThreading();
|
||||
}
|
||||
|
||||
osg::notify(osg::INFO)<<"Viewer::startThreading() - starting threading"<<std::endl;
|
||||
// using multi-threading so make sure that new objects are allocated with thread safe ref/unref
|
||||
osg::Referenced::setThreadSafeReferenceCounting(true);
|
||||
|
||||
if (getSceneData())
|
||||
{
|
||||
// make sure that existing scene graph objects are allocated with thread safe ref/unref
|
||||
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.
|
||||
getSceneData()->resizeGLObjectBuffers(osg::DisplaySettings::instance()->getMaxNumberOfGraphicsContexts());
|
||||
}
|
||||
|
||||
osg::notify(osg::NOTICE)<<"Viewer::startThreading() - starting threading"<<std::endl;
|
||||
|
||||
Contexts contexts;
|
||||
getContexts(contexts);
|
||||
@@ -320,7 +332,6 @@ void Viewer::realize()
|
||||
++citr)
|
||||
{
|
||||
(*citr)->realize();
|
||||
// OpenThreads::Thread::YieldCurrentThread();
|
||||
}
|
||||
|
||||
bool grabFocus = true;
|
||||
@@ -336,8 +347,9 @@ void Viewer::realize()
|
||||
gw->grabFocusIfPointerInWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
startThreading();
|
||||
|
||||
// initialize the global timer to be relative to the current time.
|
||||
|
||||
Reference in New Issue
Block a user