CMake: Do not create file system node in main thread

The file system scanning was already in a thread, but creating a tree
from the flat list of file nodes was still done in the main thread.
Creating the tree looks for and creates folder nodes as needed for each
file node, which is not that big of a deal but still takes 1/3 of a
second for the Qt Creator source tree.

Task-number: QTCREATORBUG-25783
Change-Id: I28948ed3ff5233f6fc4b86e93da94d882b81e231
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Eike Ziller
2021-06-16 11:33:35 +02:00
parent fd6ec7da25
commit 9109a6895e
13 changed files with 191 additions and 95 deletions

View File

@@ -213,7 +213,7 @@ CMakeBuildSystem::~CMakeBuildSystem()
delete m_cppCodeModelUpdater;
qDeleteAll(m_extraCompilers);
qDeleteAll(m_allFiles);
qDeleteAll(m_allFiles.allFiles);
}
void CMakeBuildSystem::triggerParsing()
@@ -244,7 +244,7 @@ void CMakeBuildSystem::triggerParsing()
qCDebug(cmakeBuildSystemLog) << "ParseGuard acquired.";
if (m_allFiles.isEmpty()) {
if (m_allFiles.allFiles.isEmpty()) {
qCDebug(cmakeBuildSystemLog)
<< "No treescanner information available, forcing treescanner run.";
updateReparseParameters(REPARSE_SCAN);
@@ -466,8 +466,8 @@ void CMakeBuildSystem::handleTreeScanningFinished()
{
QTC_CHECK(m_waitingForScan);
qDeleteAll(m_allFiles);
m_allFiles = Utils::transform(m_treeScanner.release(), [](const FileNode *fn) { return fn; });
qDeleteAll(m_allFiles.allFiles);
m_allFiles = m_treeScanner.release();
m_waitingForScan = false;
@@ -528,7 +528,7 @@ void CMakeBuildSystem::clearCMakeCache()
}
std::unique_ptr<CMakeProjectNode> CMakeBuildSystem::generateProjectTree(
const QList<const FileNode *> &allFiles, bool includeHeaderNodes)
const TreeScanner::Result &allFiles, bool includeHeaderNodes)
{
QString errorMessage;
auto root = m_reader.generateProjectTree(allFiles, errorMessage, includeHeaderNodes);