summaryrefslogtreecommitdiff
path: root/src/plugins/clangtools
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2021-05-28 16:53:36 +0200
committerhjk <hjk@qt.io>2021-06-14 05:46:16 +0000
commit0b7e71ddca956d8a12215479f441a743f38c1909 (patch)
tree6ef0fbb6f5aa1f61af93fc18ead3486d2833bd18 /src/plugins/clangtools
parent95a7dc48571f1686f54f003b06fa7e29258b9126 (diff)
downloadqt-creator-0b7e71ddca956d8a12215479f441a743f38c1909.tar.gz
ClangTools: Don't double-buffer in ClangToolRunner
Not needed, and the only user of QtcProcess::readyRead. Change-Id: I6ba071507f545076cf74660c20916407c3f3a551 Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/clangtools')
-rw-r--r--src/plugins/clangtools/clangtoolrunner.cpp30
-rw-r--r--src/plugins/clangtools/clangtoolrunner.h3
2 files changed, 11 insertions, 22 deletions
diff --git a/src/plugins/clangtools/clangtoolrunner.cpp b/src/plugins/clangtools/clangtoolrunner.cpp
index 28135553af..0450255074 100644
--- a/src/plugins/clangtools/clangtoolrunner.cpp
+++ b/src/plugins/clangtools/clangtoolrunner.cpp
@@ -87,7 +87,6 @@ void ClangToolRunner::init(const QString &outputDirPath, const Environment &envi
m_process->setWorkingDirectory(m_outputDirPath); // Current clang-cl puts log file into working dir.
connect(m_process, &QtcProcess::finished, this, &ClangToolRunner::onProcessFinished);
connect(m_process, &QtcProcess::errorOccurred, this, &ClangToolRunner::onProcessError);
- connect(m_process, &QtcProcess::readyRead, this, &ClangToolRunner::onProcessOutput);
}
QStringList ClangToolRunner::mainToolArguments() const
@@ -136,7 +135,6 @@ bool ClangToolRunner::run(const QString &fileToAnalyze, const QStringList &compi
QTC_CHECK(!compilerOptions.contains(fileToAnalyze));
m_fileToAnalyze = fileToAnalyze;
- m_processOutput.clear();
m_outputFilePath = createOutputFilePath(m_outputDirPath, fileToAnalyze);
QTC_ASSERT(!m_outputFilePath.isEmpty(), return false);
@@ -148,17 +146,14 @@ bool ClangToolRunner::run(const QString &fileToAnalyze, const QStringList &compi
return true;
}
-void ClangToolRunner::onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
+void ClangToolRunner::onProcessFinished()
{
- if (exitStatus == QProcess::NormalExit) {
- if (exitCode == 0) {
- qCDebug(LOG).noquote() << "Output:\n" << QtcProcess::normalizeNewlines(
- QString::fromLocal8Bit(m_processOutput));
- emit finishedWithSuccess(m_fileToAnalyze);
- } else {
- emit finishedWithFailure(finishedWithBadExitCode(m_name, exitCode),
- commandlineAndOutput());
- }
+ if (m_process->result() == QtcProcess::FinishedWithSuccess) {
+ qCDebug(LOG).noquote() << "Output:\n" << m_process->stdOut();
+ emit finishedWithSuccess(m_fileToAnalyze);
+ } else if (m_process->result() == QtcProcess::FinishedWithError) {
+ emit finishedWithFailure(finishedWithBadExitCode(m_name, m_process->exitCode()),
+ commandlineAndOutput());
} else { // == QProcess::CrashExit
emit finishedWithFailure(finishedDueToCrash(m_name), commandlineAndOutput());
}
@@ -172,19 +167,14 @@ void ClangToolRunner::onProcessError(QProcess::ProcessError error)
emit finishedWithFailure(generalProcessError(m_name), commandlineAndOutput());
}
-void ClangToolRunner::onProcessOutput()
-{
- m_processOutput.append(m_process->readAllStandardOutput());
-}
-
QString ClangToolRunner::commandlineAndOutput() const
{
return tr("Command line: %1\n"
"Process Error: %2\n"
"Output:\n%3")
- .arg(m_commandLine.toUserOutput(),
- QString::number(m_process->error()),
- QtcProcess::normalizeNewlines(QString::fromLocal8Bit(m_processOutput)));
+ .arg(m_commandLine.toUserOutput())
+ .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 d42967da35..811d360508 100644
--- a/src/plugins/clangtools/clangtoolrunner.h
+++ b/src/plugins/clangtools/clangtoolrunner.h
@@ -73,7 +73,7 @@ protected:
private:
void onProcessOutput();
- void onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
+ void onProcessFinished();
void onProcessError(QProcess::ProcessError error);
QString commandlineAndOutput() const;
@@ -81,7 +81,6 @@ private:
private:
QString m_outputDirPath;
Utils::QtcProcess *m_process = nullptr;
- QByteArray m_processOutput;
QString m_name;
QString m_executable;