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 #include #include @@ -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 diff --git a/src/plugins/clangtools/clangtoolrunner.h b/src/plugins/clangtools/clangtoolrunner.h index 988aa56f48d..6df1213642b 100644 --- a/src/plugins/clangtools/clangtoolrunner.h +++ b/src/plugins/clangtools/clangtoolrunner.h @@ -28,13 +28,10 @@ #include "clangtoolslogfilereader.h" #include - -#include +#include #include -namespace Utils { class QtcProcess; } - namespace ClangTools { namespace Internal { @@ -46,7 +43,6 @@ class ClangToolRunner : public QObject public: ClangToolRunner(QObject *parent = nullptr); - ~ClangToolRunner() override; void init(const Utils::FilePath &outputDirPath, const Utils::Environment &environment); void setName(const QString &name) { m_name = name; } @@ -83,7 +79,7 @@ private: private: Utils::FilePath m_outputDirPath; - Utils::QtcProcess *m_process = nullptr; + Utils::QtcProcess m_process; QString m_name; Utils::FilePath m_executable;