aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2022-02-08 16:17:48 +0100
committerJarek Kobus <jaroslaw.kobus@qt.io>2022-02-09 12:34:57 +0000
commit072750a284516d141933595b9e2652c370b64c47 (patch)
tree3c30b6857f71a4f603a69d7c9d9c1be70d219826
parentff68923846e30b8b23947c3a107d0e0aec3df4dc (diff)
Fix crash reporting in output pane when remote run in terminal
Fixes: QTCREATORBUG-27007 Change-Id: I6e409eb6489530dc6c48c90d20e28ff019eff187 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
-rw-r--r--src/libs/ssh/sshremoteprocess.cpp2
-rw-r--r--src/plugins/projectexplorer/applicationlauncher.cpp3
-rw-r--r--src/plugins/projectexplorer/runcontrol.cpp76
-rw-r--r--src/plugins/projectexplorer/runcontrol.h1
4 files changed, 31 insertions, 51 deletions
diff --git a/src/libs/ssh/sshremoteprocess.cpp b/src/libs/ssh/sshremoteprocess.cpp
index bbfec939eb..0cb916acf1 100644
--- a/src/libs/ssh/sshremoteprocess.cpp
+++ b/src/libs/ssh/sshremoteprocess.cpp
@@ -60,8 +60,6 @@ SshRemoteProcess::SshRemoteProcess(const QString &command, const QStringList &co
QString error;
if (exitStatus() == QProcess::CrashExit)
error = tr("The ssh process crashed: %1").arg(errorString());
- else if (exitCode() == 255)
- error = tr("Remote process crashed.");
emit done(error);
});
connect(this, &QtcProcess::errorOccurred, [this](QProcess::ProcessError error) {
diff --git a/src/plugins/projectexplorer/applicationlauncher.cpp b/src/plugins/projectexplorer/applicationlauncher.cpp
index ea9dbd4a05..2d5b5ce5fd 100644
--- a/src/plugins/projectexplorer/applicationlauncher.cpp
+++ b/src/plugins/projectexplorer/applicationlauncher.cpp
@@ -458,9 +458,6 @@ void ApplicationLauncherPrivate::handleApplicationFinished()
if (exitCode != 0) {
doReportError(ApplicationLauncher::tr("Application finished with exit code %1.")
.arg(exitCode), QProcess::UnknownError);
- } else {
- emit q->appendMessage(ApplicationLauncher::tr("Application finished with exit code 0."),
- Utils::NormalMessageFormat);
}
}
setFinished();
diff --git a/src/plugins/projectexplorer/runcontrol.cpp b/src/plugins/projectexplorer/runcontrol.cpp
index f0824ead6e..883760dfda 100644
--- a/src/plugins/projectexplorer/runcontrol.cpp
+++ b/src/plugins/projectexplorer/runcontrol.cpp
@@ -1196,6 +1196,7 @@ void SimpleTargetRunner::start()
void SimpleTargetRunner::doStart(const Runnable &runnable, const IDevice::ConstPtr &device)
{
+ m_stopForced = false;
m_stopReported = false;
m_launcher.disconnect(this);
m_launcher.setUseTerminal(m_useTerminal);
@@ -1205,11 +1206,34 @@ void SimpleTargetRunner::doStart(const Runnable &runnable, const IDevice::ConstP
const QString msg = RunControl::tr("Starting %1...").arg(runnable.command.toUserOutput());
appendMessage(msg, Utils::NormalMessageFormat);
- if (isDesktop) {
-
- connect(&m_launcher, &ApplicationLauncher::appendMessage,
- this, &SimpleTargetRunner::appendMessage);
+ connect(&m_launcher, &ApplicationLauncher::processExited,
+ this, [this, runnable](int exitCode, QProcess::ExitStatus status) {
+ if (m_stopReported)
+ return;
+ const QString msg = (status == QProcess::CrashExit)
+ ? tr("%1 crashed.") : tr("%2 exited with code %1").arg(exitCode);
+ const QString displayName = runnable.command.executable().toUserOutput();
+ appendMessage(msg.arg(displayName), Utils::NormalMessageFormat);
+ m_stopReported = true;
+ reportStopped();
+ });
+
+ connect(&m_launcher, &ApplicationLauncher::error,
+ this, [this, runnable](QProcess::ProcessError error) {
+ if (m_stopReported)
+ return;
+ if (error == QProcess::Timedout)
+ return; // No actual change on the process side.
+ const QString msg = m_stopForced ? tr("The process was ended forcefully.")
+ : userMessageForProcessError(error, runnable.command.executable());
+ appendMessage(msg, Utils::NormalMessageFormat);
+ m_stopReported = true;
+ reportStopped();
+ });
+
+ connect(&m_launcher, &ApplicationLauncher::appendMessage, this, &RunWorker::appendMessage);
+ if (isDesktop) {
connect(&m_launcher, &ApplicationLauncher::processStarted, this, [this] {
// Console processes only know their pid after being started
ProcessHandle pid = m_launcher.applicationPID();
@@ -1218,33 +1242,6 @@ void SimpleTargetRunner::doStart(const Runnable &runnable, const IDevice::ConstP
reportStarted();
});
- connect(&m_launcher, &ApplicationLauncher::processExited,
- this, [this, runnable](int exitCode, QProcess::ExitStatus status) {
- if (m_stopReported)
- return;
- const QString msg = (status == QProcess::CrashExit)
- ? tr("%1 crashed.") : tr("%2 exited with code %1").arg(exitCode);
- const QString displayName = runnable.command.executable().toUserOutput();
- appendMessage(msg.arg(displayName), Utils::NormalMessageFormat);
- m_stopReported = true;
- reportStopped();
- });
-
- connect(&m_launcher, &ApplicationLauncher::error,
- this, [this, runnable](QProcess::ProcessError error) {
- if (error == QProcess::Timedout)
- return; // No actual change on the process side.
- if (error != QProcess::Crashed) {
- const QString msg = userMessageForProcessError(
- error, runnable.command.executable());
- appendMessage(msg, Utils::NormalMessageFormat);
- }
- if (!m_stopReported) {
- m_stopReported = true;
- reportStopped();
- }
- });
-
if (runnable.command.isEmpty()) {
reportFailure(RunControl::tr("No executable specified."));
} else {
@@ -1252,27 +1249,14 @@ void SimpleTargetRunner::doStart(const Runnable &runnable, const IDevice::ConstP
}
} else {
-
- connect(&m_launcher, &ApplicationLauncher::error, this, [this] {
- reportFailure(m_launcher.errorString());
- });
-
connect(&m_launcher, &ApplicationLauncher::processStarted, this, &RunWorker::reportStarted);
-
- connect(&m_launcher, &ApplicationLauncher::processExited,
- this, [this] {
- m_launcher.disconnect(this);
- reportStopped();
- });
-
- connect(&m_launcher, &ApplicationLauncher::appendMessage, this, &RunWorker::appendMessage);
-
m_launcher.start(runnable, device);
}
}
void SimpleTargetRunner::stop()
{
+ m_stopForced = true;
m_launcher.stop();
}
@@ -1559,7 +1543,7 @@ QString RunWorker::userMessageForProcessError(QProcess::ProcessError error, cons
"permissions to invoke the program.").arg(program.toUserOutput());
break;
case QProcess::Crashed:
- msg = tr("The process was ended forcefully.");
+ msg = tr("The process crashed.");
break;
case QProcess::Timedout:
// "The last waitFor...() function timed out. "
diff --git a/src/plugins/projectexplorer/runcontrol.h b/src/plugins/projectexplorer/runcontrol.h
index 6f00b57e97..c1ab5d6781 100644
--- a/src/plugins/projectexplorer/runcontrol.h
+++ b/src/plugins/projectexplorer/runcontrol.h
@@ -308,6 +308,7 @@ private:
bool m_stopReported = false;
bool m_useTerminal = false;
bool m_runAsRoot = false;
+ bool m_stopForced = false;
};
class PROJECTEXPLORER_EXPORT OutputFormatterFactory