diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp index 2cc69e4c9ad..6e08d1dc6af 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp @@ -114,6 +114,7 @@ CMakeBuildSystem::~CMakeBuildSystem() bool CMakeBuildSystem::validateParsingContext(const ParsingContext &ctx) { + QTC_ASSERT(!m_currentContext.guard.guardsProject(), return false); return ctx.project && qobject_cast(ctx.buildConfiguration); } diff --git a/src/plugins/projectexplorer/buildsystem.cpp b/src/plugins/projectexplorer/buildsystem.cpp index 84c9b123811..c8b33cce2e9 100644 --- a/src/plugins/projectexplorer/buildsystem.cpp +++ b/src/plugins/projectexplorer/buildsystem.cpp @@ -95,6 +95,8 @@ void BuildSystem::triggerParsing() ParsingContext ctx(p->guardParsingRun(), p, bc, e, env); + QTC_ASSERT(ctx.guard.guardsProject(), return ); + if (validateParsingContext(ctx)) parseProject(std::move(ctx)); } diff --git a/src/plugins/projectexplorer/buildsystem.h b/src/plugins/projectexplorer/buildsystem.h index dd8456074c8..521f48beb73 100644 --- a/src/plugins/projectexplorer/buildsystem.h +++ b/src/plugins/projectexplorer/buildsystem.h @@ -65,8 +65,22 @@ protected: ParsingContext(const ParsingContext &other) = delete; ParsingContext &operator=(const ParsingContext &other) = delete; - ParsingContext(ParsingContext &&other) = default; - ParsingContext &operator=(ParsingContext &&other) = default; + ParsingContext(ParsingContext &&other) + : guard{std::move(other.guard)} + , project{std::move(other.project)} + , buildConfiguration{std::move(other.buildConfiguration)} + , expander{std::move(other.expander)} + , environment{std::move(other.environment)} + {} + ParsingContext &operator=(ParsingContext &&other) + { + guard = std::move(other.guard); + project = std::move(other.project); + buildConfiguration = std::move(other.buildConfiguration); + expander = std::move(other.expander); + environment = std::move(other.environment); + return *this; + } Project::ParseGuard guard; diff --git a/src/plugins/projectexplorer/project.h b/src/plugins/projectexplorer/project.h index 9c4f38fecbe..889a924817d 100644 --- a/src/plugins/projectexplorer/project.h +++ b/src/plugins/projectexplorer/project.h @@ -192,27 +192,29 @@ public: : ParseGuard(nullptr) {} - ~ParseGuard() - { - if (m_project) - m_project->emitParsingFinished(m_success); - } + ~ParseGuard() { release(); } void markAsSuccess() const { m_success = true; } bool isSuccess() const { return m_success; } - bool isNull() const { return !m_project; } + bool guardsProject() const { return m_project; } ParseGuard(const ParseGuard &other) = delete; ParseGuard &operator=(const ParseGuard &other) = delete; ParseGuard(ParseGuard &&other) + : m_project{std::move(other.m_project)} + , m_success{std::move(other.m_success)} { - std::swap(m_project, other.m_project); - std::swap(m_success, other.m_success); + // No need to release this as this is invalid anyway:-) + other.m_project = nullptr; } ParseGuard &operator=(ParseGuard &&other) { - std::swap(m_project, other.m_project); - std::swap(m_success, other.m_success); + release(); + + m_project = std::move(other.m_project); + m_success = std::move(other.m_success); + + other.m_project = nullptr; return *this; } @@ -220,8 +222,17 @@ public: ParseGuard(Project *p) : m_project(p) { - if (m_project) + if (m_project && !m_project->isParsing()) m_project->emitParsingStarted(); + else + m_project = nullptr; + } + + void release() + { + if (m_project) + m_project->emitParsingFinished(m_success); + m_project = nullptr; } Project *m_project = nullptr;