From 6854d2968f4ec9a1290db3023ead27bfa4fb74a2 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 20 Mar 2015 11:48:21 +0000 Subject: [PATCH] From Jannik Heller, "Fix for Qt4 multi-threaded crash. This patch adds the AA_X11InitThreads flag to the QApplication setup, meaning QT will call XInitThreads for us. This also bumps the required QT version to 4.8+, because the AA_X11InitThreads flag was introduced in that version. If that is not acceptable, we could add a QT_VERSION >= 0x040800 guard, or manually call XInitThreads() instead. Let me know what you think." git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14804 16af8721-9629-0410-8352-f15c8da7e697 --- examples/osgviewerQt/osgviewerQt.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/osgviewerQt/osgviewerQt.cpp b/examples/osgviewerQt/osgviewerQt.cpp index e2e1f3fcc..ec4c302c4 100644 --- a/examples/osgviewerQt/osgviewerQt.cpp +++ b/examples/osgviewerQt/osgviewerQt.cpp @@ -105,6 +105,12 @@ int main( int argc, char** argv ) while (arguments.read("--DrawThreadPerContext")) threadingModel = osgViewer::ViewerBase::DrawThreadPerContext; while (arguments.read("--CullThreadPerCameraDrawThreadPerContext")) threadingModel = osgViewer::ViewerBase::CullThreadPerCameraDrawThreadPerContext; +#if QT_VERSION >= 0x040800 + // Required for multithreaded QGLWidget on Linux/X11, see http://blog.qt.io/blog/2011/06/03/threaded-opengl-in-4-8/ + if (threadingModel != osgViewer::ViewerBase::SingleThreaded) + QApplication::setAttribute(Qt::AA_X11InitThreads); +#endif + QApplication app(argc, argv); ViewerWidget* viewWidget = new ViewerWidget(0, Qt::Widget, threadingModel); viewWidget->setGeometry( 100, 100, 800, 600 );