summaryrefslogtreecommitdiffstats
path: root/src/quick3d/imports/scene3d/scene3drenderer.cpp
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2016-05-17 18:23:20 +0100
committerSean Harmer <sean.harmer@kdab.com>2016-05-20 18:18:25 +0000
commit9ffb65683ae756697bfc98490d25c71e66fc77f8 (patch)
tree046222ab193623fc0ff5ebfb0bfb7b018afd8960 /src/quick3d/imports/scene3d/scene3drenderer.cpp
parent0edb64686801d7ad3b9c245e8c6d7058718c84c3 (diff)
Allow the QtQuick + Scene3D case to shutdown cleanly
...by having the Scene3D item exit the simulation loop before asking the renderer to shutdown. This is necessary because if we let the simulation loop keep running then the render aspect keeps creating and executing jobs as we pull the rug out form under it by shutting down the renderer. This exhibited quite regularly as a crash caused by a race in the Shader::cleanup() function which tried to access the GraphicsContext that was destroyed by the renderer shutdown. This approach sequences things very similarly to the pure Qt 3D shutdown method. The main difference is that we explicitly stop the simulation loop whereas in the pure Qt 3D case, that is done for us by the QAspectEngine::setRootEntity(null) call. This is still done in the QAspectEngine dtor but by that time, the simulation loop is already stopped. The exit simulation logic has been adapted to handle this case. Task-number: QTBUG-51035 Task-number: QTBUG-42353 Change-Id: I08d16e301eab421fa6eb99e558f38e832534c151 Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
Diffstat (limited to 'src/quick3d/imports/scene3d/scene3drenderer.cpp')
-rw-r--r--src/quick3d/imports/scene3d/scene3drenderer.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/quick3d/imports/scene3d/scene3drenderer.cpp b/src/quick3d/imports/scene3d/scene3drenderer.cpp
index 24b42e15d..44a57e039 100644
--- a/src/quick3d/imports/scene3d/scene3drenderer.cpp
+++ b/src/quick3d/imports/scene3d/scene3drenderer.cpp
@@ -46,6 +46,7 @@
#include <Qt3DRender/qrenderaspect.h>
#include <Qt3DRender/private/qrenderaspect_p.h>
#include <Qt3DCore/qaspectengine.h>
+#include <Qt3DCore/private/qaspectengine_p.h>
#include <QtQuick/qquickwindow.h>
@@ -177,6 +178,11 @@ void Scene3DRenderer::shutdown()
// would return early
m_item = nullptr;
+ // Exit the simulation loop so no more jobs are asked for. Once this
+ // returns it is safe to shutdown the renderer.
+ auto engineD = Qt3DCore::QAspectEnginePrivate::get(m_aspectEngine);
+ engineD->exitSimulationLoop();
+
// Shutdown the Renderer Aspect while the OpenGL context
// is still valid
if (m_renderAspect)