diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2019-10-04 07:56:20 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2019-10-16 09:59:58 +0000 |
commit | 4e6b2cd0b6ee275ef38392e7e0b0ab2de6718bb4 (patch) | |
tree | c9260c421b3695cfafb7d216b42829529a4e576c | |
parent | e76193605ab725bbb004f3ff8b1c2af973803d31 (diff) | |
download | qt3d-4e6b2cd0b6ee275ef38392e7e0b0ab2de6718bb4.tar.gz |
Renderer: check context thread before destroying resources
Only try to cleanup the resources if we know we are called from the right
thread.
releaseGraphicsResources can be called from 2 places:
- Scene3DCleaner when using Scene3D (when closing the window)
- AspectThread when the RenderAspect gets unregistered
In configurations where the context lives in the main thread (Scene3D +
single threaded render loop / ANGLE), the RenderAspect gets unregistered
before the Scene3DCleaner has had time to call releaseGraphicsResources.
This means that we won't release the resources ourselved and that the
driver will have to do that for us.
This has been fixed properly in 5.14 with the AspectThread removal.
Task-number: QTBUG-60971
Change-Id: I49c1c2f74ad09e7162b988f87bac65863f8490d8
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
(cherry picked from commit f60a57ebe0e9a4449fb0f8f28a38c0f69b3f845e)
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r-- | src/render/renderers/opengl/renderer/renderer.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/render/renderers/opengl/renderer/renderer.cpp b/src/render/renderers/opengl/renderer/renderer.cpp index b3aa80fc2..f32862bfd 100644 --- a/src/render/renderers/opengl/renderer/renderer.cpp +++ b/src/render/renderers/opengl/renderer/renderer.cpp @@ -512,7 +512,8 @@ void Renderer::releaseGraphicsResources() QOpenGLContext *context = m_submissionContext->openGLContext(); Q_ASSERT(context); - if (context->makeCurrent(offscreenSurface)) { + + if (context->thread() == QThread::currentThread() && context->makeCurrent(offscreenSurface)) { // Clean up the graphics context and any resources const QVector<GLTexture*> activeTextures = m_nodesManager->glTextureManager()->activeResources(); |