diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2020-12-07 15:19:35 +0100 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2020-12-07 16:24:57 +0000 |
commit | a0079b171f98865d34f3e5750b87da8e86968d0a (patch) | |
tree | 655c19ce5a81b4e3aaa46665ff107c934753a360 /src/libs/cplusplus/DependencyTable.cpp | |
parent | 43249f655be5b676fd324c9ce1e0cd0a7cd48fd0 (diff) | |
download | qt-creator-a0079b171f98865d34f3e5750b87da8e86968d0a.tar.gz |
Make canceling of Type Hierarchy evaluation more responsive
On the beginning of the process of evaluating type hierarchy
the evaluating thread may freeze on a first call to
Snapshot::updateDependencyTable() for quite a long time
(e.g. when showing the type hierarchy for IPlugin class
inside Creator project - it may freeze up to about 3 seconds).
So, when we want to cancel the evaluation (e.g. when
we switch from "Type Hierarchy" into another view or when
closing Creator) we may freeze for this period. In order to
fix it we pass a future interface as an additional argument
for Snapshot::updateDependencyTable() and cancel the update
when cancellation of task was requested.
Change-Id: I2147f10a68989587476c30369ec2ac552a57d5ae
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/libs/cplusplus/DependencyTable.cpp')
-rw-r--r-- | src/libs/cplusplus/DependencyTable.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/libs/cplusplus/DependencyTable.cpp b/src/libs/cplusplus/DependencyTable.cpp index 4a2b71d053..2f6b4600f8 100644 --- a/src/libs/cplusplus/DependencyTable.cpp +++ b/src/libs/cplusplus/DependencyTable.cpp @@ -26,6 +26,7 @@ #include "CppDocument.h" #include <QDebug> +#include <QFutureInterface> using namespace CPlusPlus; @@ -47,13 +48,16 @@ Utils::FilePaths DependencyTable::filesDependingOn(const Utils::FilePath &fileNa return deps; } -void DependencyTable::build(const Snapshot &snapshot) +void DependencyTable::build(QFutureInterfaceBase &futureInterface, const Snapshot &snapshot) { files.clear(); fileIndex.clear(); includes.clear(); includeMap.clear(); + if (futureInterface.isCanceled()) + return; + const int documentCount = snapshot.size(); files.resize(documentCount); includeMap.resize(documentCount); @@ -65,6 +69,9 @@ void DependencyTable::build(const Snapshot &snapshot) fileIndex[it.key()] = i; } + if (futureInterface.isCanceled()) + return; + for (int i = 0; i < files.size(); ++i) { const Utils::FilePath &fileName = files.at(i); if (Document::Ptr doc = snapshot.document(fileName)) { @@ -81,10 +88,14 @@ void DependencyTable::build(const Snapshot &snapshot) directIncludes.append(index); bitmap.setBit(index, true); + if (futureInterface.isCanceled()) + return; } includeMap[i] = bitmap; includes[i] = directIncludes; + if (futureInterface.isCanceled()) + return; } } @@ -99,12 +110,18 @@ void DependencyTable::build(const Snapshot &snapshot) foreach (int includedFileIndex, includes.value(i)) { bitmap |= includeMap.value(includedFileIndex); + if (futureInterface.isCanceled()) + return; } if (bitmap != previousBitmap) { includeMap[i] = bitmap; changed = true; } + if (futureInterface.isCanceled()) + return; } + if (futureInterface.isCanceled()) + return; } while (changed); } |