ProjectExplorer: Use RAII pattern for parsing start/stop signalling

Change-Id: I13de537140f265db3e3d0ab1cd924d6897cd90c8
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Tobias Hunger
2019-08-06 14:46:37 +02:00
parent 8868989d5c
commit 09530d6dcc
18 changed files with 143 additions and 69 deletions

View File

@@ -43,14 +43,18 @@ using namespace Utils;
namespace CompilationDatabaseProjectManager {
namespace Internal {
CompilationDbParser::CompilationDbParser(const QString &projectName, const FilePath &projectPath,
const FilePath &rootPath, MimeBinaryCache &mimeBinaryCache,
CompilationDbParser::CompilationDbParser(const QString &projectName,
const FilePath &projectPath,
const FilePath &rootPath,
MimeBinaryCache &mimeBinaryCache,
ProjectExplorer::Project::ParseGuard &&guard,
QObject *parent)
: QObject(parent),
m_projectName(projectName),
m_projectFilePath(projectPath),
m_rootPath(rootPath),
m_mimeBinaryCache(mimeBinaryCache)
: QObject(parent)
, m_projectName(projectName)
, m_projectFilePath(projectPath)
, m_rootPath(rootPath)
, m_mimeBinaryCache(mimeBinaryCache)
, m_guard(std::move(guard))
{
connect(&m_parserWatcher, &QFutureWatcher<void>::finished, this, [this] {
m_dbContents = m_parserWatcher.result();
@@ -112,6 +116,7 @@ void CompilationDbParser::stop()
m_treeScanner->disconnect();
m_treeScanner->future().cancel();
}
m_guard = {};
deleteLater();
}