From e07c6383d7e6bc7f44e0820fa1a33a9470397a60 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Mon, 27 Feb 2017 17:25:58 +0100 Subject: ProjectExplorer: Unify RunControl setup/teardown Provide protected methods in RunControl to handle the notification of when the RunControl starts and stops. Use these helpers to move the isRunning() method into the RunConfiguration itself instead of reimplementing it everywhere. Change-Id: Ia8de42f7a6a14a049870d4e7fcb9af6756c2caa4 Reviewed-by: Maurice Kalinowski Reviewed-by: hjk Reviewed-by: Ulf Hermann Reviewed-by: Christian Kandeler Reviewed-by: Tim Jenssen --- .../clangstaticanalyzerruncontrol.cpp | 22 +++++++--------------- .../clangstaticanalyzerruncontrol.h | 2 -- 2 files changed, 7 insertions(+), 17 deletions(-) (limited to 'src/plugins/clangstaticanalyzer') diff --git a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp index 544832013a..019b0632b5 100644 --- a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp +++ b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp @@ -469,7 +469,7 @@ void ClangStaticAnalyzerRunControl::start() m_success = false; emit starting(); - QTC_ASSERT(m_projectInfo.isValid(), emit finished(); return); + QTC_ASSERT(m_projectInfo.isValid(), reportApplicationStop(); return); const Utils::FileName projectFile = m_projectInfo.project()->projectFilePath(); appendMessage(tr("Running Clang Static Analyzer on %1").arg(projectFile.toUserOutput()) + QLatin1Char('\n'), Utils::NormalMessageFormat); @@ -485,7 +485,7 @@ void ClangStaticAnalyzerRunControl::start() appendMessage(errorMessage + QLatin1Char('\n'), Utils::ErrorMessageFormat); TaskHub::addTask(Task::Error, errorMessage, Debugger::Constants::ANALYZERTASK_ID); TaskHub::requestPopup(); - emit finished(); + reportApplicationStop(); return; } @@ -522,7 +522,7 @@ void ClangStaticAnalyzerRunControl::start() appendMessage(errorMessage + QLatin1Char('\n'), Utils::ErrorMessageFormat); TaskHub::addTask(Task::Error, errorMessage, Debugger::Constants::ANALYZERTASK_ID); TaskHub::requestPopup(); - emit finished(); + reportApplicationStop(); return; } m_clangLogFileDir = temporaryDir.path(); @@ -550,16 +550,15 @@ void ClangStaticAnalyzerRunControl::start() qCDebug(LOG) << "Environment:" << m_environment; m_runners.clear(); const int parallelRuns = ClangStaticAnalyzerSettings::instance()->simultaneousProcesses(); - QTC_ASSERT(parallelRuns >= 1, emit finished(); return); + QTC_ASSERT(parallelRuns >= 1, reportApplicationStop(); return); m_success = true; - m_running = true; if (m_unitsToProcess.isEmpty()) { finalize(); return; } - emit started(); + reportApplicationStart(); while (m_runners.size() < parallelRuns && !m_unitsToProcess.isEmpty()) analyzeNextFile(); @@ -578,16 +577,10 @@ RunControl::StopResult ClangStaticAnalyzerRunControl::stop() appendMessage(tr("Clang Static Analyzer stopped by user.") + QLatin1Char('\n'), Utils::NormalMessageFormat); m_progress.reportFinished(); - m_running = false; - emit finished(); + reportApplicationStop(); return RunControl::StoppedSynchronously; } -bool ClangStaticAnalyzerRunControl::isRunning() const -{ - return m_running; -} - void ClangStaticAnalyzerRunControl::analyzeNextFile() { if (m_progress.isFinished()) @@ -701,8 +694,7 @@ void ClangStaticAnalyzerRunControl::finalize() } m_progress.reportFinished(); - m_running = false; - emit finished(); + reportApplicationStop(); } } // namespace Internal diff --git a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h index ce974bac37..9776de88d2 100644 --- a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h +++ b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h @@ -58,7 +58,6 @@ public: void start() override; StopResult stop() override; - bool isRunning() const override; bool success() const { return m_success; } // For testing. bool supportsReRunning() const override { return false; } @@ -95,7 +94,6 @@ private: int m_filesAnalyzed; int m_filesNotAnalyzed; bool m_success; - bool m_running = false; }; } // namespace Internal -- cgit v1.2.1