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>
This commit is contained in:
Mike Krus 2020-01-27 10:54:01 +00:00
parent df5a63b059
commit 650d065d3b
2 changed files with 4 additions and 1 deletions

View File

@ -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);

View File

@ -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()