CompilationDbProjectManager: Fix tree scanning

- We checked for the QFuture's canceled status at a time where it would
  always yield true.
- A pointless default value was used for the project root path.

Fixes: QTCREATORBUG-26356
Change-Id: I4d17c6ecb7e9e7e71df737d85b42feb37d3ead5d
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2021-10-21 14:05:40 +02:00
parent 0a7935d449
commit 9f7cdd6d3c
2 changed files with 8 additions and 11 deletions

View File

@@ -437,17 +437,14 @@ CompilationDatabaseProject::CompilationDatabaseProject(const Utils::FilePath &pr
Utils::FilePath CompilationDatabaseProject::rootPathFromSettings() const Utils::FilePath CompilationDatabaseProject::rootPathFromSettings() const
{ {
#ifdef WITH_TESTS Utils::FilePath rootPath;
return Utils::FilePath::fromString(projectDirectory().fileName()); #ifndef WITH_TESTS
#else rootPath = Utils::FilePath::fromString(
auto rootPath = Utils::FilePath::fromString(
namedSettings(ProjectExplorer::Constants::PROJECT_ROOT_PATH_KEY).toString()); namedSettings(ProjectExplorer::Constants::PROJECT_ROOT_PATH_KEY).toString());
if (rootPath.isEmpty())
rootPath = Utils::FilePath::fromString(projectDirectory().fileName());
return rootPath;
#endif #endif
if (rootPath.isEmpty())
rootPath = projectDirectory();
return rootPath;
} }
void CompilationDatabaseProject::configureAsExampleProject(Kit *kit) void CompilationDatabaseProject::configureAsExampleProject(Kit *kit)

View File

@@ -138,9 +138,9 @@ void CompilationDbParser::stop()
QList<FileNode *> CompilationDbParser::scannedFiles() const QList<FileNode *> CompilationDbParser::scannedFiles() const
{ {
const bool canceled = m_treeScanner->future().isCanceled();
const TreeScanner::Result result = m_treeScanner->release(); const TreeScanner::Result result = m_treeScanner->release();
return m_treeScanner && !m_treeScanner->future().isCanceled() ? result.allFiles return !canceled ? result.allFiles : QList<FileNode *>();
: QList<FileNode *>();
} }
void CompilationDbParser::parserJobFinished() void CompilationDbParser::parserJobFinished()