diff options
3 files changed, 21 insertions, 10 deletions
diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp b/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp index 595514697e..86939bdfd9 100644 --- a/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp +++ b/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp @@ -53,7 +53,6 @@ ClangStaticAnalyzerRunControl::ClangStaticAnalyzerRunControl( ProjectExplorer::RunConfiguration *runConfiguration) : AnalyzerRunControl(startParams, runConfiguration) , m_initialFilesToProcessSize(0) - , m_runningProcesses(0) { } @@ -135,17 +134,25 @@ bool ClangStaticAnalyzerRunControl::startEngine() m_progress.reportStarted(); // Start process(es) + m_runners.clear(); const int parallelRuns = ClangStaticAnalyzerSettings::instance()->simultaneousProcesses(); QTC_ASSERT(parallelRuns >= 1, emit finished(); return false); - m_runningProcesses = 0; - while (m_runningProcesses < parallelRuns && !m_filesToProcess.isEmpty()) + while (m_runners.size() < parallelRuns && !m_filesToProcess.isEmpty()) analyzeNextFile(); return true; } void ClangStaticAnalyzerRunControl::stopEngine() { + QSetIterator<ClangStaticAnalyzerRunner *> i(m_runners); + while (i.hasNext()) { + ClangStaticAnalyzerRunner *runner = i.next(); + QObject::disconnect(runner, 0, this, 0); + delete runner; + } + m_runners.clear(); m_filesToProcess.clear(); + analyzeNextFile(); // emits finished } void ClangStaticAnalyzerRunControl::analyzeNextFile() @@ -154,8 +161,7 @@ void ClangStaticAnalyzerRunControl::analyzeNextFile() return; // The previous call already reported that we are finished. if (m_filesToProcess.isEmpty()) { - QTC_ASSERT(m_runningProcesses >= 0, return); - if (m_runningProcesses == 0) { + if (m_runners.size() == 0) { m_progress.reportFinished(); emit finished(); } @@ -167,9 +173,9 @@ void ClangStaticAnalyzerRunControl::analyzeNextFile() const QStringList options = config.createClangOptions(); ClangStaticAnalyzerRunner *runner = createRunner(); + m_runners.insert(runner); qCDebug(LOG) << "analyzeNextFile:" << filePath; QTC_ASSERT(runner->run(filePath, options), return); - ++m_runningProcesses; } ClangStaticAnalyzerRunner *ClangStaticAnalyzerRunControl::createRunner() @@ -208,7 +214,7 @@ void ClangStaticAnalyzerRunControl::onRunnerFinishedWithFailure(const QString &e void ClangStaticAnalyzerRunControl::handleFinished() { - --m_runningProcesses; + m_runners.remove(qobject_cast<ClangStaticAnalyzerRunner *>(sender())); updateProgressValue(); sender()->deleteLater(); analyzeNextFile(); diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h b/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h index 036793571e..661594bf11 100644 --- a/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h +++ b/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h @@ -74,8 +74,8 @@ private: QString m_clangLogFileDir; QFutureInterface<void> m_progress; QList<SourceFileConfiguration> m_filesToProcess; + QSet<ClangStaticAnalyzerRunner *> m_runners; int m_initialFilesToProcessSize; - int m_runningProcesses; }; } // namespace Internal diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzerrunner.cpp b/plugins/clangstaticanalyzer/clangstaticanalyzerrunner.cpp index e3c63625bf..ed8efb93f8 100644 --- a/plugins/clangstaticanalyzer/clangstaticanalyzerrunner.cpp +++ b/plugins/clangstaticanalyzer/clangstaticanalyzerrunner.cpp @@ -84,8 +84,13 @@ ClangStaticAnalyzerRunner::ClangStaticAnalyzerRunner(const QString &clangExecuta ClangStaticAnalyzerRunner::~ClangStaticAnalyzerRunner() { const QProcess::ProcessState processState = m_process.state(); - if (processState == QProcess::Starting || processState == QProcess::Running) - m_process.kill(); + if (processState == QProcess::Starting || processState == QProcess::Running) { + m_process.terminate(); + if (!m_process.waitForFinished(500)) { + m_process.kill(); + m_process.waitForFinished(); + } + } } bool ClangStaticAnalyzerRunner::run(const QString &filePath, const QStringList &compilerOptions) |