-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
4.8.5
-
Mac OS X 10.7
Application below crashes on Mac (10.7). Works on Windows (7).
Application works when creating QFrameBufferObject also in gui thread. See comment line from main.cpp.
Doesn't work on Qt 5.1.1 at all. Displays error:"Cannot make QOpenGLContext current in a different thread".
main.cpp
#include <QApplication> #include <QFutureWatcher> #include <QFutureSynchronizer> #include <QtConcurrentRun> #include <QThread> #include <QGLWidget> #include <QGLFramebufferObject> void threadTask(QGLWidget *glWidget, int i) { qDebug() << "task:" << i << " thread: " << QThread::currentThreadId(); glWidget->makeCurrent(); QGLFramebufferObject * frameBufferObject = new QGLFramebufferObject(QSize(128, 128)); glWidget->doneCurrent(); } int main(int argc, char ** argv) { QApplication app(argc, argv); qDebug() << "ideal thread count" << QThread::idealThreadCount(); QGLWidget * glWidget = new QGLWidget(); QFutureSynchronizer<void> * futures = new QFutureSynchronizer<void>(); for(int i=0; i<20; i++) { QGLWidget * threadWidget = new QGLWidget(glWidget); threadWidget->makeCurrent(); // !!! NEED TO CREATE FBO HERE OR IT CRASH! !!! //QGLFramebufferObject * frameBufferObject = new QGLFramebufferObject(QSize(128, 128)); threadWidget->doneCurrent(); futures->addFuture(QtConcurrent::run(threadTask, threadWidget, i)); } futures->waitForFinished(); glWidget->show(); return( app.exec() ); }
project.pro
TEMPLATE = app QT = core gui opengl greaterThan(QT_MAJOR_VERSION, 4): QT += widgets concurrent CONFIG -= app_bundle SOURCES += main.cpp