forked from qt-creator/qt-creator
CppElementEvaluator: Use QtConcurrent invocation for async run
Change-Id: Idc67ecd4e9e95c5893a04ca1a9ee7b30662ec664 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -821,16 +821,10 @@ FilePaths Snapshot::filesDependingOn(const FilePath &filePath) const
|
||||
return m_deps.filesDependingOn(filePath);
|
||||
}
|
||||
|
||||
void Snapshot::updateDependencyTable() const
|
||||
{
|
||||
QFutureInterfaceBase futureInterface;
|
||||
updateDependencyTable(futureInterface);
|
||||
}
|
||||
|
||||
void Snapshot::updateDependencyTable(QFutureInterfaceBase &futureInterface) const
|
||||
void Snapshot::updateDependencyTable(const std::optional<QFuture<void>> &future) const
|
||||
{
|
||||
if (m_deps.files.isEmpty())
|
||||
m_deps.build(futureInterface, *this);
|
||||
m_deps.build(future, *this);
|
||||
}
|
||||
|
||||
bool Snapshot::operator==(const Snapshot &other) const
|
||||
|
||||
@@ -15,12 +15,9 @@
|
||||
#include <QDateTime>
|
||||
#include <QHash>
|
||||
#include <QFileInfo>
|
||||
#include <QFuture>
|
||||
#include <QAtomicInt>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QFutureInterfaceBase;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class Macro;
|
||||
@@ -406,8 +403,7 @@ public:
|
||||
|
||||
Utils::FilePaths filesDependingOn(const Utils::FilePath &filePath) const;
|
||||
|
||||
void updateDependencyTable() const;
|
||||
void updateDependencyTable(QFutureInterfaceBase &futureInterface) const;
|
||||
void updateDependencyTable(const std::optional<QFuture<void>> &future = {}) const;
|
||||
|
||||
bool operator==(const Snapshot &other) const;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "CppDocument.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFutureInterface>
|
||||
#include <QFuture>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
@@ -28,14 +28,14 @@ Utils::FilePaths DependencyTable::filesDependingOn(const Utils::FilePath &fileNa
|
||||
return deps;
|
||||
}
|
||||
|
||||
void DependencyTable::build(QFutureInterfaceBase &futureInterface, const Snapshot &snapshot)
|
||||
void DependencyTable::build(const std::optional<QFuture<void>> &future, const Snapshot &snapshot)
|
||||
{
|
||||
files.clear();
|
||||
fileIndex.clear();
|
||||
includes.clear();
|
||||
includeMap.clear();
|
||||
|
||||
if (futureInterface.isCanceled())
|
||||
if (future && future->isCanceled())
|
||||
return;
|
||||
|
||||
const int documentCount = snapshot.size();
|
||||
@@ -49,7 +49,7 @@ void DependencyTable::build(QFutureInterfaceBase &futureInterface, const Snapsho
|
||||
fileIndex[it.key()] = i;
|
||||
}
|
||||
|
||||
if (futureInterface.isCanceled())
|
||||
if (future && future->isCanceled())
|
||||
return;
|
||||
|
||||
for (int i = 0; i < files.size(); ++i) {
|
||||
@@ -68,13 +68,13 @@ void DependencyTable::build(QFutureInterfaceBase &futureInterface, const Snapsho
|
||||
directIncludes.append(index);
|
||||
|
||||
bitmap.setBit(index, true);
|
||||
if (futureInterface.isCanceled())
|
||||
if (future && future->isCanceled())
|
||||
return;
|
||||
}
|
||||
|
||||
includeMap[i] = bitmap;
|
||||
includes[i] = directIncludes;
|
||||
if (futureInterface.isCanceled())
|
||||
if (future && future->isCanceled())
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ void DependencyTable::build(QFutureInterfaceBase &futureInterface, const Snapsho
|
||||
const QList<int> includedFileIndexes = includes.value(i);
|
||||
for (const int includedFileIndex : includedFileIndexes) {
|
||||
bitmap |= includeMap.value(includedFileIndex);
|
||||
if (futureInterface.isCanceled())
|
||||
if (future && future->isCanceled())
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -99,10 +99,10 @@ void DependencyTable::build(QFutureInterfaceBase &futureInterface, const Snapsho
|
||||
includeMap[i] = bitmap;
|
||||
changed = true;
|
||||
}
|
||||
if (futureInterface.isCanceled())
|
||||
if (future && future->isCanceled())
|
||||
return;
|
||||
}
|
||||
if (futureInterface.isCanceled())
|
||||
if (future && future->isCanceled())
|
||||
return;
|
||||
} while (changed);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
#include <QVector>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QFutureInterfaceBase;
|
||||
template <typename T>
|
||||
class QFuture;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace CPlusPlus {
|
||||
@@ -25,7 +26,7 @@ class CPLUSPLUS_EXPORT DependencyTable
|
||||
{
|
||||
private:
|
||||
friend class Snapshot;
|
||||
void build(QFutureInterfaceBase &futureInterface, const Snapshot &snapshot);
|
||||
void build(const std::optional<QFuture<void>> &future, const Snapshot &snapshot);
|
||||
Utils::FilePaths filesDependingOn(const Utils::FilePath &fileName) const;
|
||||
|
||||
QVector<Utils::FilePath> files;
|
||||
|
||||
Reference in New Issue
Block a user