diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-04-21 13:43:16 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-04-21 14:30:10 +0200 |
commit | 763752ded1cbd7a64c623434de666fca6619541b (patch) | |
tree | be4c05fcd02896ae062b25cfd39a3de44d7808d8 | |
parent | 1d7965fc418cfad97df582b8307b939737318985 (diff) |
Avoid using qGuiApp in QOpenGLVao::destroy()
There are convoluted cases, based on the backtrace attached
to the associated bug report, where we attempt to destroy a
QOpenGLVertexArrayObject during the destruction of Q(Gui)Application.
Just avoid accessing qGuiApp in destroy(). Rather, store it in create().
Fixes: QTBUG-75138
Pick-to: 5.15
Change-Id: If8e67301c0843cbf3a409dcf427f44c42079de2f
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
-rw-r--r-- | src/opengl/qopenglvertexarrayobject.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/opengl/qopenglvertexarrayobject.cpp b/src/opengl/qopenglvertexarrayobject.cpp index 9c85d73c22..7f28a0bc61 100644 --- a/src/opengl/qopenglvertexarrayobject.cpp +++ b/src/opengl/qopenglvertexarrayobject.cpp @@ -103,6 +103,7 @@ public: : vao(0) , vaoFuncsType(NotSupported) , context(nullptr) + , guiThread(nullptr) { } @@ -137,6 +138,7 @@ public: } vaoFuncsType; QOpenGLContext *context; + QThread *guiThread; }; bool QOpenGLVertexArrayObjectPrivate::create() @@ -161,6 +163,8 @@ bool QOpenGLVertexArrayObjectPrivate::create() context = ctx; QObject::connect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed())); + guiThread = qGuiApp->thread(); + if (ctx->isOpenGLES()) { if (ctx->format().majorVersion() >= 3 || ctx->hasExtension(QByteArrayLiteral("GL_OES_vertex_array_object"))) { vaoFuncs.helper = new QOpenGLVertexArrayObjectHelper(ctx); @@ -210,7 +214,7 @@ void QOpenGLVertexArrayObjectPrivate::destroy() // Before going through the effort of creating an offscreen surface // check that we are on the GUI thread because otherwise many platforms // will not able to create that offscreen surface. - if (QThread::currentThread() != qGuiApp->thread()) { + if (QThread::currentThread() != guiThread) { ctx = nullptr; } else { // Cannot just make the current surface current again with another context. |