From 118883f66a7039506b788a8df4f5606017e45242 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Fri, 17 Sep 2021 10:29:36 +0200 Subject: [PATCH] qmake: Fix crash with Qt 6 when canceling parsing In Qt 5, QFutureWatcher::isFinished was only true if the finished signal was already sent. That changed in Qt 6, where it represents the state of the QFuture instead. Use an explicit bool for representing "finished signal was sent" instead. Task-number: QTCREATORBUG-24098 Change-Id: I4dd8e1c7f6659b2856634d522fb1c0f7eef6741b Reviewed-by: Christian Kandeler --- src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp | 11 ++++++----- src/plugins/qmakeprojectmanager/qmakeparsernodes.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp b/src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp index 3bed8f42e95..fd059a23f43 100644 --- a/src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp @@ -1189,7 +1189,7 @@ QmakeProFile::~QmakeProFile() m_parseFutureWatcher->cancel(); m_parseFutureWatcher->waitForFinished(); if (m_readerExact) - applyAsyncEvaluate(); + applyAsyncEvaluate(false); delete m_parseFutureWatcher; } cleanupProFileReaders(); @@ -1198,8 +1198,9 @@ QmakeProFile::~QmakeProFile() void QmakeProFile::setupFutureWatcher() { m_parseFutureWatcher = new QFutureWatcher; - QObject::connect(m_parseFutureWatcher, &QFutureWatcherBase::finished, - [this](){ applyAsyncEvaluate(); }); + QObject::connect(m_parseFutureWatcher, &QFutureWatcherBase::finished, [this]() { + applyAsyncEvaluate(true); + }); } bool QmakeProFile::isParent(QmakeProFile *node) @@ -1643,9 +1644,9 @@ void QmakeProFile::asyncEvaluate(QFutureInterface &fi, QmakeE fi.reportResult(evalResult); } -void QmakeProFile::applyAsyncEvaluate() +void QmakeProFile::applyAsyncEvaluate(bool apply) { - if (m_parseFutureWatcher->isFinished()) + if (apply) applyEvaluate(m_parseFutureWatcher->result()); m_buildSystem->decrementPendingEvaluateFutures(); } diff --git a/src/plugins/qmakeprojectmanager/qmakeparsernodes.h b/src/plugins/qmakeprojectmanager/qmakeparsernodes.h index 836c04e5890..9d1121c2fb0 100644 --- a/src/plugins/qmakeprojectmanager/qmakeparsernodes.h +++ b/src/plugins/qmakeprojectmanager/qmakeparsernodes.h @@ -352,7 +352,7 @@ private: void setParseInProgress(bool b); void setValidParseRecursive(bool b); - void applyAsyncEvaluate(); + void applyAsyncEvaluate(bool apply); void setupReader(); Internal::QmakeEvalInput evalInput() const;