forked from qt-creator/qt-creator
ProjectExplorer: React to QtcProcess::done in ApplicationLauncher
The 'modern' way. Change-Id: I80c0bb0b9c7c08e6aef724d430a8dbbd4b0c2777 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -72,7 +72,7 @@ public:
|
||||
|
||||
~ApplicationLauncherPrivate() override {
|
||||
if (m_state == Run)
|
||||
emit q->finished();
|
||||
emit q->done();
|
||||
}
|
||||
|
||||
void start();
|
||||
@@ -178,7 +178,7 @@ void ApplicationLauncherPrivate::stop()
|
||||
if (!isRunning())
|
||||
return;
|
||||
m_process.stopProcess();
|
||||
QTimer::singleShot(100, this, [this] { emit q->finished(); });
|
||||
QTimer::singleShot(100, this, [this] { emit q->done(); });
|
||||
} else {
|
||||
if (m_stopRequested)
|
||||
return;
|
||||
@@ -224,7 +224,7 @@ void ApplicationLauncherPrivate::handleDone()
|
||||
|
||||
if (m_isLocal) {
|
||||
if (m_resultData.m_error == QProcess::UnknownError) {
|
||||
emit q->finished();
|
||||
emit q->done();
|
||||
return;
|
||||
}
|
||||
// TODO: why below handlings are different?
|
||||
@@ -233,7 +233,6 @@ void ApplicationLauncherPrivate::handleDone()
|
||||
if (m_processRunning && m_process.processId() == 0) {
|
||||
m_processRunning = false;
|
||||
m_resultData.m_exitCode = -1; // FIXME: Why?
|
||||
emit q->finished();
|
||||
}
|
||||
} else {
|
||||
QString errorString;
|
||||
@@ -252,23 +251,19 @@ void ApplicationLauncherPrivate::handleDone()
|
||||
if (m_processRunning && !isRunning()) {
|
||||
m_processRunning = false;
|
||||
m_resultData.m_exitCode = -1;
|
||||
emit q->finished();
|
||||
}
|
||||
}
|
||||
emit q->errorOccurred(m_resultData.m_error);
|
||||
|
||||
} else {
|
||||
QTC_ASSERT(m_state == Run, return);
|
||||
QTC_ASSERT(m_state == Run, emit q->done(); return);
|
||||
if (m_resultData.m_error == QProcess::FailedToStart) {
|
||||
m_resultData.m_exitStatus = QProcess::CrashExit;
|
||||
emit q->errorOccurred(m_resultData.m_error);
|
||||
} else if (m_resultData.m_exitStatus == QProcess::CrashExit) {
|
||||
m_resultData.m_error = QProcess::Crashed;
|
||||
emit q->errorOccurred(m_resultData.m_error);
|
||||
}
|
||||
m_state = Inactive;
|
||||
emit q->finished();
|
||||
}
|
||||
emit q->done();
|
||||
}
|
||||
|
||||
void ApplicationLauncherPrivate::handleStandardOutput()
|
||||
@@ -312,6 +307,11 @@ QProcess::ExitStatus ApplicationLauncher::exitStatus() const
|
||||
return d->m_resultData.m_exitStatus;
|
||||
}
|
||||
|
||||
QProcess::ProcessError ApplicationLauncher::error() const
|
||||
{
|
||||
return d->m_resultData.m_error;
|
||||
}
|
||||
|
||||
void ApplicationLauncher::start()
|
||||
{
|
||||
d->start();
|
||||
@@ -357,8 +357,7 @@ void ApplicationLauncherPrivate::start()
|
||||
m_resultData.m_errorString = ApplicationLauncher::tr("Cannot run: No device.");
|
||||
m_resultData.m_error = QProcess::FailedToStart;
|
||||
m_resultData.m_exitStatus = QProcess::CrashExit;
|
||||
emit q->errorOccurred(QProcess::FailedToStart);
|
||||
emit q->finished();
|
||||
emit q->done();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -366,8 +365,7 @@ void ApplicationLauncherPrivate::start()
|
||||
m_resultData.m_errorString = ApplicationLauncher::tr("Cannot run: No command given.");
|
||||
m_resultData.m_error = QProcess::FailedToStart;
|
||||
m_resultData.m_exitStatus = QProcess::CrashExit;
|
||||
emit q->errorOccurred(QProcess::FailedToStart);
|
||||
emit q->finished();
|
||||
emit q->done();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -63,12 +63,12 @@ public:
|
||||
|
||||
int exitCode() const;
|
||||
QProcess::ExitStatus exitStatus() const;
|
||||
QProcess::ProcessError error() const;
|
||||
|
||||
signals:
|
||||
void appendMessage(const QString &message, Utils::OutputFormat format, bool appendNewLine = true);
|
||||
void started();
|
||||
void finished();
|
||||
void errorOccurred(QProcess::ProcessError error);
|
||||
void done();
|
||||
|
||||
private:
|
||||
std::unique_ptr<Internal::ApplicationLauncherPrivate> d;
|
||||
|
@@ -1220,30 +1220,22 @@ void SimpleTargetRunner::doStart(const Runnable &runnable)
|
||||
const QString msg = RunControl::tr("Starting %1...").arg(runnable.command.toUserOutput());
|
||||
appendMessage(msg, Utils::NormalMessageFormat);
|
||||
|
||||
connect(&m_launcher, &ApplicationLauncher::finished, this, [this, runnable]() {
|
||||
connect(&m_launcher, &ApplicationLauncher::done, this, [this, runnable] {
|
||||
if (m_stopReported)
|
||||
return;
|
||||
const QString msg = (m_launcher.exitStatus() == QProcess::CrashExit)
|
||||
? tr("%1 crashed.") : tr("%2 exited with code %1").arg(m_launcher.exitCode());
|
||||
QString msg = tr("%2 exited with code %1").arg(m_launcher.exitCode());
|
||||
if (m_launcher.exitStatus() == QProcess::CrashExit)
|
||||
msg = tr("%1 crashed.");
|
||||
else if (m_stopForced)
|
||||
msg = tr("The process was ended forcefully.");
|
||||
else if (m_launcher.error() != QProcess::UnknownError)
|
||||
msg = userMessageForProcessError(m_launcher.error(), runnable.command.executable());
|
||||
const QString displayName = runnable.command.executable().toUserOutput();
|
||||
appendMessage(msg.arg(displayName), Utils::NormalMessageFormat);
|
||||
m_stopReported = true;
|
||||
reportStopped();
|
||||
});
|
||||
|
||||
connect(&m_launcher, &ApplicationLauncher::errorOccurred,
|
||||
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);
|
||||
|
||||
const bool isDesktop = runnable.device.isNull()
|
||||
|
Reference in New Issue
Block a user