summaryrefslogtreecommitdiffstats
path: root/src/quick3d/imports/scene3d
diff options
context:
space:
mode:
authorMauro Persano <mauro.persano@kdab.com>2016-01-15 18:31:19 +0000
committerSean Harmer <sean.harmer@kdab.com>2016-01-15 18:32:13 +0000
commit8b820e8f93c851c08941a4eead519588d2135c3d (patch)
tree6f08a8b7e7807359224406c791114c79d7ce2f44 /src/quick3d/imports/scene3d
parentc1dc4aaa3b9ec08510ef4246b779d999391a3b3d (diff)
Revert "Fix crash when Scene3DItem is removed from scene"
This reverts commit 658d7bee705224c9e2fbbab1d5e79d32c99858f7. The problem that this commit tried to fix still exists, but the commit seems to have just replaced a kind of shutdown crash with a different one. Change-Id: Ic34b4da9798269c2ed8b02992c811c2129eb5673 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/quick3d/imports/scene3d')
-rw-r--r--src/quick3d/imports/scene3d/scene3ditem.cpp65
-rw-r--r--src/quick3d/imports/scene3d/scene3ditem_p.h1
2 files changed, 32 insertions, 34 deletions
diff --git a/src/quick3d/imports/scene3d/scene3ditem.cpp b/src/quick3d/imports/scene3d/scene3ditem.cpp
index 2e55c52ee..ef839ae87 100644
--- a/src/quick3d/imports/scene3d/scene3ditem.cpp
+++ b/src/quick3d/imports/scene3d/scene3ditem.cpp
@@ -96,8 +96,9 @@ class Scene3DSGNode;
\li The window is closed
- \li Scene3DItem is notified via itemChange() and calls shutdown() on Scene3DRenderer,
- which performs the necessary cleanups in the QSGRenderThread (destroys DebugLogger ...).
+ \li This triggers the windowsChanged signal which the Scene3DRenderer
+ uses to perform the necessary cleanups in the QSGRenderThread (destroys
+ DebugLogger ...) with the shutdown slot (queued connection).
\li The destroyed signal of the window is also connected to the
Scene3DRenderer. When triggered in the context of the main thread, the
@@ -162,6 +163,7 @@ public:
Q_CHECK_PTR(m_item->window());
QObject::connect(m_item->window(), &QQuickWindow::beforeRendering, this, &Scene3DRenderer::render, Qt::DirectConnection);
+ QObject::connect(m_item, &QQuickItem::windowChanged, this, &Scene3DRenderer::onWindowChangedQueued, Qt::QueuedConnection);
ContextSaver saver;
@@ -213,12 +215,37 @@ public:
void synchronize();
- // Executed in the QtQuick render thread.
- void shutdown();
-
public Q_SLOTS:
void render();
+ // Executed in the QtQuick render thread.
+ void shutdown()
+ {
+ qCDebug(Scene3D) << Q_FUNC_INFO << QThread::currentThread();
+
+ // Set to null so that subsequent calls to render
+ // would return early
+ m_item = Q_NULLPTR;
+
+ // Shutdown the Renderer Aspect while the OpenGL context
+ // is still valid
+ if (m_renderAspect)
+ m_renderAspect->renderShutdown();
+ }
+
+ // SGThread
+ void onWindowChangedQueued(QQuickWindow *w)
+ {
+ if (w == Q_NULLPTR) {
+ qCDebug(Scene3D) << Q_FUNC_INFO << QThread::currentThread();
+ shutdown();
+ // Will only trigger something with the Loader case
+ // The window closed cases is handled by the window's destroyed
+ // signal
+ QMetaObject::invokeMethod(m_cleaner, "cleanup");
+ }
+ }
+
private:
Scene3DItem *m_item; // Will be released by the QQuickWindow/QML Engine
Qt3DCore::QAspectEngine *m_aspectEngine; // Will be released by the Scene3DRendererCleaner
@@ -538,15 +565,6 @@ void Scene3DItem::setMultisample(bool enable)
}
}
-void Scene3DItem::itemChange(ItemChange change, const ItemChangeData& value)
-{
- // Are we being removed from the scene?
- if (change == QQuickItem::ItemSceneChange && value.window == Q_NULLPTR)
- m_renderer->shutdown();
-
- QQuickItem::itemChange(change, value);
-}
-
QSGNode *Scene3DItem::updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNodeData *)
{
// If the node already exists
@@ -576,25 +594,6 @@ void Scene3DRenderer::synchronize()
m_multisample = m_item->multisample();
}
-void Scene3DRenderer::shutdown()
-{
- qCDebug(Scene3D) << Q_FUNC_INFO << QThread::currentThread();
-
- // Set to null so that subsequent calls to render
- // would return early
- m_item = Q_NULLPTR;
-
- // Shutdown the Renderer Aspect while the OpenGL context
- // is still valid
- if (m_renderAspect)
- m_renderAspect->renderShutdown();
-
- // Will only trigger something with the Loader case
- // The window closed cases is handled by the window's destroyed
- // signal
- QMetaObject::invokeMethod(m_cleaner, "cleanup");
-}
-
void Scene3DRenderer::setSGNode(Scene3DSGNode *node) Q_DECL_NOEXCEPT
{
m_node = node;
diff --git a/src/quick3d/imports/scene3d/scene3ditem_p.h b/src/quick3d/imports/scene3d/scene3ditem_p.h
index 1b9335203..edb0b7b00 100644
--- a/src/quick3d/imports/scene3d/scene3ditem_p.h
+++ b/src/quick3d/imports/scene3d/scene3ditem_p.h
@@ -93,7 +93,6 @@ private Q_SLOTS:
void applyRootEntityChange();
private:
- void itemChange(ItemChange change, const ItemChangeData& value);
QSGNode *updatePaintNode(QSGNode *node, UpdatePaintNodeData *nodeData) Q_DECL_OVERRIDE;
QStringList m_aspects;