summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMäättä Antti <antti.maatta@qt.io>2018-02-05 13:42:52 +0200
committerSean Harmer <sean.harmer@kdab.com>2018-02-06 10:22:15 +0000
commit564dfd87c5b1317dcf9fbc4d1c8d858c72513421 (patch)
tree234d798a036020cb9abc8b45bd2e185a172d8d6e
parentceae743678d41a58154612781e896c04c87a8c4f (diff)
Fix crash in scene2d at shutdown
The resource manager policy for scene2d nodes has been changed so the scene2d constructor gets called multiple times at startup. That in turn increments render thread user counter every time. The cleanup code gets called for each instanciated QScene2D node so at shutdown the counter never reaches zero and the render thread is not closed properly. Change the implementation so that the counter gets incremented only when the render thread has been properly initialized. Task-number: QTBUG-66003 Change-Id: I33a5b1f407e65329776bcabe0b66ff049581a435 Reviewed-by: Svenn-Arne Dragly <svenn-arne.dragly@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Paul Lemire <paul.lemire@kdab.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r--src/quick3d/quick3dscene2d/items/scene2d.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/quick3d/quick3dscene2d/items/scene2d.cpp b/src/quick3d/quick3dscene2d/items/scene2d.cpp
index 13a253063..38c2e30f3 100644
--- a/src/quick3d/quick3dscene2d/items/scene2d.cpp
+++ b/src/quick3d/quick3dscene2d/items/scene2d.cpp
@@ -121,7 +121,7 @@ Scene2D::Scene2D()
, m_mouseEnabled(true)
, m_renderPolicy(Qt3DRender::Quick::QScene2D::Continuous)
{
- renderThreadClientCount->fetchAndAddAcquire(1);
+
}
Scene2D::~Scene2D()
@@ -144,6 +144,8 @@ void Scene2D::initializeSharedObject()
return;
}
+ renderThreadClientCount->fetchAndAddAcquire(1);
+
renderThread->setObjectName(QStringLiteral("Scene2D::renderThread"));
m_renderThread = renderThread;
m_sharedObject->m_renderThread = m_renderThread;
@@ -411,10 +413,11 @@ void Scene2D::cleanup()
m_sharedObject->wake();
m_sharedObject = nullptr;
}
-
- renderThreadClientCount->fetchAndSubAcquire(1);
- if (renderThreadClientCount->load() == 0)
- renderThread->quit();
+ if (m_renderThread) {
+ renderThreadClientCount->fetchAndSubAcquire(1);
+ if (renderThreadClientCount->load() == 0)
+ renderThread->quit();
+ }
}