CompilationDbProjectManager: Sanitize project parsing

The parsing code used to access all kinds of stuff (e.g. the project
tree and the toolchain manager) from the non-UI thread, which is not
allowed.

Fixes: QTCREATORBUG-22420
Change-Id: I4be47919d7e543376d31826dd380f66f4e060458
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Christian Kandeler
2019-05-16 15:36:55 +02:00
parent 975173af11
commit 0ffbe6a9e4
9 changed files with 385 additions and 181 deletions

View File

@@ -25,14 +25,19 @@
#pragma once
#include "compilationdatabaseutils.h"
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/project.h>
#include <projectexplorer/treescanner.h>
#include <texteditor/texteditor.h>
#include <utils/filesystemwatcher.h>
#include <QFutureWatcher>
QT_BEGIN_NAMESPACE
class QTimer;
QT_END_NAMESPACE
namespace CppTools {
class CppProjectUpdater;
}
@@ -43,6 +48,7 @@ class Kit;
namespace CompilationDatabaseProjectManager {
namespace Internal {
class CompilationDbParser;
class CompilationDatabaseProject : public ProjectExplorer::Project
{
@@ -58,15 +64,16 @@ private:
RestoreResult fromMap(const QVariantMap &map, QString *errorMessage) override;
void reparseProject();
void buildTreeAndProjectParts(const Utils::FileName &projectFile);
void buildTreeAndProjectParts();
Utils::FileName rootPathFromSettings() const;
QFutureWatcher<void> m_parserWatcher;
std::unique_ptr<CppTools::CppProjectUpdater> m_cppCodeModelUpdater;
std::unique_ptr<ProjectExplorer::Kit> m_kit;
Utils::FileSystemWatcher m_fileSystemWatcher;
ProjectExplorer::TreeScanner m_treeScanner;
QHash<QString, bool> m_mimeBinaryCache;
MimeBinaryCache m_mimeBinaryCache;
QTimer * const m_parseDelay;
CompilationDbParser *m_parser = nullptr;
bool m_hasTarget = false;
};