From c53e846ab9a2a6264f3a79d49ae770bd0a617684 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 6 Apr 2022 09:34:46 +0200 Subject: [PATCH] ExternalToolRunner: Connect to QtcProcess::done() signal Instead of connecting to errorOccurred() and finished() signals. Change-Id: I8f201f508b60ae795a4f7dfbbb4edb3d3fe8b030 Reviewed-by: Eike Ziller Reviewed-by: --- src/plugins/coreplugin/externaltool.cpp | 24 +++++++++--------------- src/plugins/coreplugin/externaltool.h | 3 +-- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/plugins/coreplugin/externaltool.cpp b/src/plugins/coreplugin/externaltool.cpp index 2ef5e7e9ca5..ac3ef7796cb 100644 --- a/src/plugins/coreplugin/externaltool.cpp +++ b/src/plugins/coreplugin/externaltool.cpp @@ -647,8 +647,7 @@ void ExternalToolRunner::run() } } m_process = new QtcProcess(this); - connect(m_process, &QtcProcess::finished, this, &ExternalToolRunner::finished); - connect(m_process, &QtcProcess::errorOccurred, this, &ExternalToolRunner::error); + connect(m_process, &QtcProcess::done, this, &ExternalToolRunner::done); connect(m_process, &QtcProcess::readyReadStandardOutput, this, &ExternalToolRunner::readStandardOutput); connect(m_process, &QtcProcess::readyReadStandardError, @@ -667,28 +666,23 @@ void ExternalToolRunner::run() m_process->start(); } -void ExternalToolRunner::finished() +void ExternalToolRunner::done() { if (m_process->result() == ProcessResult::FinishedWithSuccess - && (m_tool->outputHandling() == ExternalTool::ReplaceSelection - || m_tool->errorHandling() == ExternalTool::ReplaceSelection)) { + && (m_tool->outputHandling() == ExternalTool::ReplaceSelection + || m_tool->errorHandling() == ExternalTool::ReplaceSelection)) { ExternalToolManager::emitReplaceSelectionRequested(m_processOutput); } + const QString message = (m_process->result() == ProcessResult::FinishedWithSuccess) + ? tr("\"%1\" finished").arg(m_resolvedExecutable.toUserOutput()) + : tr("\"%1\" finished with error").arg(m_resolvedExecutable.toUserOutput()); + if (m_tool->modifiesCurrentDocument()) DocumentManager::unexpectFileChange(m_expectedFilePath); const auto write = m_tool->outputHandling() == ExternalTool::ShowInPane ? QOverload::of(MessageManager::writeFlashing) : QOverload::of(MessageManager::writeSilently); - write(tr("\"%1\" finished").arg(m_resolvedExecutable.toUserOutput())); - deleteLater(); -} - -void ExternalToolRunner::error(QProcess::ProcessError error) -{ - if (m_tool->modifiesCurrentDocument()) - DocumentManager::unexpectFileChange(m_expectedFilePath); - // TODO inform about errors - Q_UNUSED(error) + write(message); deleteLater(); } diff --git a/src/plugins/coreplugin/externaltool.h b/src/plugins/coreplugin/externaltool.h index caec43258c1..a1e16f10f56 100644 --- a/src/plugins/coreplugin/externaltool.h +++ b/src/plugins/coreplugin/externaltool.h @@ -135,8 +135,7 @@ public: QString errorString() const; private: - void finished(); - void error(QProcess::ProcessError error); + void done(); void readStandardOutput(); void readStandardError();