aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/clangtools/clangtoolrunner.cpp
diff options
context:
space:
mode:
authorhjk <[email protected]>2022-06-16 10:34:01 +0200
committerhjk <[email protected]>2022-06-16 11:20:56 +0000
commit189fe7fab37591e1cc43a322d019e7e980c5dedb (patch)
treec6cb253c7d96e53f22f020f26b259b3dd1133571 /src/plugins/clangtools/clangtoolrunner.cpp
parent706dc654b996f7fa35fddbed40e6b555cc3cb1b4 (diff)
ClangTools: Simplify process rampdown
This is now taken care of in the desctuctor of QtcProcess itself. Change-Id: I51e65344e6d2cae4498e292e4ad6a586c68b0539 Reviewed-by: Jarek Kobus <[email protected]> Reviewed-by: David Schulz <[email protected]>
Diffstat (limited to 'src/plugins/clangtools/clangtoolrunner.cpp')
-rw-r--r--src/plugins/clangtools/clangtoolrunner.cpp44
1 files changed, 13 insertions, 31 deletions
diff --git a/src/plugins/clangtools/clangtoolrunner.cpp b/src/plugins/clangtools/clangtoolrunner.cpp
index ab5ef389899..c602203a24d 100644
--- a/src/plugins/clangtools/clangtoolrunner.cpp
+++ b/src/plugins/clangtools/clangtoolrunner.cpp
@@ -25,8 +25,6 @@
#include "clangtoolrunner.h"
-#include "clangtoolsconstants.h"
-
#include <utils/environment.h>
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
@@ -60,33 +58,17 @@ static QString finishedWithBadExitCode(const QString &name, int exitCode)
}
ClangToolRunner::ClangToolRunner(QObject *parent)
- : QObject(parent), m_process(new QtcProcess)
+ : QObject(parent)
{}
-ClangToolRunner::~ClangToolRunner()
-{
- if (m_process->state() != QProcess::NotRunning) {
- // asking politly to terminate costs ~300 ms on windows so skip the courtasy and direct kill the process
- if (HostOsInfo::isWindowsHost()) {
- m_process->kill();
- m_process->waitForFinished(100);
- } else {
- m_process->stop();
- m_process->waitForFinished();
- }
- }
-
- m_process->deleteLater();
-}
-
void ClangToolRunner::init(const FilePath &outputDirPath, const Environment &environment)
{
m_outputDirPath = outputDirPath;
QTC_CHECK(!m_outputDirPath.isEmpty());
- m_process->setEnvironment(environment);
- m_process->setWorkingDirectory(m_outputDirPath); // Current clang-cl puts log file into working dir.
- connect(m_process, &QtcProcess::done, this, &ClangToolRunner::onProcessDone);
+ m_process.setEnvironment(environment);
+ m_process.setWorkingDirectory(m_outputDirPath); // Current clang-cl puts log file into working dir.
+ connect(&m_process, &QtcProcess::done, this, &ClangToolRunner::onProcessDone);
}
QStringList ClangToolRunner::mainToolArguments() const
@@ -140,20 +122,20 @@ bool ClangToolRunner::run(const QString &fileToAnalyze, const QStringList &compi
m_commandLine = {m_executable, m_argsCreator(compilerOptions)};
qCDebug(LOG).noquote() << "Starting" << m_commandLine.toUserOutput();
- m_process->setCommand(m_commandLine);
- m_process->start();
+ m_process.setCommand(m_commandLine);
+ m_process.start();
return true;
}
void ClangToolRunner::onProcessDone()
{
- if (m_process->result() == ProcessResult::StartFailed) {
+ if (m_process.result() == ProcessResult::StartFailed) {
emit finishedWithFailure(generalProcessError(m_name), commandlineAndOutput());
- } else if (m_process->result() == ProcessResult::FinishedWithSuccess) {
- qCDebug(LOG).noquote() << "Output:\n" << m_process->stdOut();
+ } else if (m_process.result() == ProcessResult::FinishedWithSuccess) {
+ qCDebug(LOG).noquote() << "Output:\n" << m_process.stdOut();
emit finishedWithSuccess(m_fileToAnalyze);
- } else if (m_process->result() == ProcessResult::FinishedWithError) {
- emit finishedWithFailure(finishedWithBadExitCode(m_name, m_process->exitCode()),
+ } else if (m_process.result() == ProcessResult::FinishedWithError) {
+ emit finishedWithFailure(finishedWithBadExitCode(m_name, m_process.exitCode()),
commandlineAndOutput());
} else { // == QProcess::CrashExit
emit finishedWithFailure(finishedDueToCrash(m_name), commandlineAndOutput());
@@ -166,8 +148,8 @@ QString ClangToolRunner::commandlineAndOutput() const
"Process Error: %2\n"
"Output:\n%3")
.arg(m_commandLine.toUserOutput())
- .arg(m_process->error())
- .arg(m_process->stdOut());
+ .arg(m_process.error())
+ .arg(m_process.stdOut());
}
} // namespace Internal