diff options
author | Mike Krus <mike.krus@kdab.com> | 2020-01-27 10:54:01 +0000 |
---|---|---|
committer | Mike Krus <mike.krus@kdab.com> | 2020-01-27 11:05:12 +0000 |
commit | 650d065d3b03825ff97600902c164d447cbb771a (patch) | |
tree | aa3aec39323c658c1e0f4b4f2e5c04a09ce9cfd6 | |
parent | df5a63b059956e8a717db9110327cc86612cc934 (diff) |
Fix potential crash when logic aspect exits
Logic aspect does work in response to posted event. By that
time the aspect may be gone (due to normal shutdown) and the scene
pointer be invalid.
Change-Id: Ia9454532a7c95cd3c00e8b225b8d95c178471a67
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r-- | src/logic/executor.cpp | 4 | ||||
-rw-r--r-- | src/logic/qlogicaspect.cpp | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/logic/executor.cpp b/src/logic/executor.cpp index 1c428db47..41d2f2e31 100644 --- a/src/logic/executor.cpp +++ b/src/logic/executor.cpp @@ -89,7 +89,9 @@ bool Executor::event(QEvent *e) */ void Executor::processLogicFrameUpdates(float dt) { - Q_ASSERT(m_scene); + if (!m_scene || m_nodeIds.isEmpty()) + return; + const QVector<QNode *> nodes = m_scene->lookupNodes(m_nodeIds); for (QNode *node : nodes) { QFrameAction *frameAction = qobject_cast<QFrameAction *>(node); diff --git a/src/logic/qlogicaspect.cpp b/src/logic/qlogicaspect.cpp index 649a14f25..c4459a84d 100644 --- a/src/logic/qlogicaspect.cpp +++ b/src/logic/qlogicaspect.cpp @@ -84,6 +84,7 @@ void QLogicAspectPrivate::onEngineAboutToShutdown() // Throw away any pending work that may deadlock during the shutdown procedure // when the main thread waits for any queued jobs to finish. m_executor->clearQueueAndProceed(); + m_executor->setScene(nullptr); } void QLogicAspectPrivate::registerBackendTypes() |