forked from qt-creator/qt-creator
Uniform ApplicationLauncher API: get rid of reportError()
Use existing error() signal instead. Implement errorString() and processError() in non-local case. Change-Id: Ibdd6cec19ffa5efa0dad330515988da80e86e35b Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -79,8 +79,8 @@ public:
|
||||
{
|
||||
connect(&m_appRunner, &ApplicationLauncher::appendMessage, this,
|
||||
&DeviceApplicationObserver::handleAppendMessage);
|
||||
connect(&m_appRunner, &ApplicationLauncher::reportError, this,
|
||||
&DeviceApplicationObserver::handleError);
|
||||
connect(&m_appRunner, &ApplicationLauncher::error, this,
|
||||
[this] { m_error = m_appRunner.errorString(); });
|
||||
connect(&m_appRunner, &ApplicationLauncher::finished, this,
|
||||
&DeviceApplicationObserver::handleFinished);
|
||||
|
||||
@@ -102,7 +102,6 @@ private:
|
||||
else if (format == Utils::StdErrFormat)
|
||||
m_stderr += data;
|
||||
}
|
||||
void handleError(const QString &message) { m_error = message; }
|
||||
|
||||
void handleFinished(bool success)
|
||||
{
|
||||
|
@@ -88,8 +88,8 @@ void QdbStopApplicationService::handleAppendMessage(const QString &message, Util
|
||||
|
||||
void QdbStopApplicationService::doDeploy()
|
||||
{
|
||||
connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::reportError,
|
||||
this, &QdbStopApplicationService::stdErrData);
|
||||
connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::error,
|
||||
this, [this] { emit stdErrData(d->applicationLauncher.errorString()); });
|
||||
connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::finished,
|
||||
this, &QdbStopApplicationService::handleProcessFinished);
|
||||
connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::appendMessage,
|
||||
|
@@ -88,7 +88,8 @@ public:
|
||||
bool isRunning() const;
|
||||
|
||||
// Remote
|
||||
void doReportError(const QString &message);
|
||||
void doReportError(const QString &message,
|
||||
QProcess::ProcessError error = QProcess::FailedToStart);
|
||||
void handleRemoteStderr();
|
||||
void handleRemoteStdout();
|
||||
void handleApplicationFinished();
|
||||
@@ -116,6 +117,8 @@ public:
|
||||
|
||||
// Remote
|
||||
DeviceProcess *m_deviceProcess = nullptr;
|
||||
QString m_remoteErrorString;
|
||||
QProcess::ProcessError m_remoteError = QProcess::UnknownError;
|
||||
State m_state = Inactive;
|
||||
bool m_stopRequested = false;
|
||||
bool m_success = false;
|
||||
@@ -258,18 +261,16 @@ qint64 ApplicationLauncherPrivate::applicationPID() const
|
||||
|
||||
QString ApplicationLauncher::errorString() const
|
||||
{
|
||||
if (d->m_useTerminal)
|
||||
return d->m_consoleProcess.errorString();
|
||||
else
|
||||
return d->m_guiProcess.errorString();
|
||||
if (d->m_isLocal)
|
||||
return d->m_useTerminal ? d->m_consoleProcess.errorString() : d->m_guiProcess.errorString();
|
||||
return d->m_remoteErrorString;
|
||||
}
|
||||
|
||||
QProcess::ProcessError ApplicationLauncher::processError() const
|
||||
{
|
||||
if (d->m_useTerminal)
|
||||
return d->m_consoleProcess.error();
|
||||
else
|
||||
return d->m_guiProcess.error();
|
||||
if (d->m_isLocal)
|
||||
return d->m_useTerminal ? d->m_consoleProcess.error() : d->m_guiProcess.error();
|
||||
return d->m_remoteError;
|
||||
}
|
||||
|
||||
void ApplicationLauncherPrivate::localGuiProcessError()
|
||||
@@ -469,11 +470,12 @@ void ApplicationLauncherPrivate::handleApplicationFinished()
|
||||
QTC_ASSERT(m_state == Run, return);
|
||||
|
||||
if (m_deviceProcess->exitStatus() == QProcess::CrashExit) {
|
||||
doReportError(m_deviceProcess->errorString());
|
||||
doReportError(m_deviceProcess->errorString(), QProcess::Crashed);
|
||||
} else {
|
||||
const int exitCode = m_deviceProcess->exitCode();
|
||||
if (exitCode != 0) {
|
||||
doReportError(ApplicationLauncher::tr("Application finished with exit code %1.").arg(exitCode));
|
||||
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);
|
||||
@@ -496,10 +498,12 @@ void ApplicationLauncherPrivate::handleRemoteStderr()
|
||||
emit q->appendMessage(QString::fromUtf8(output), Utils::StdErrFormat, false);
|
||||
}
|
||||
|
||||
void ApplicationLauncherPrivate::doReportError(const QString &message)
|
||||
void ApplicationLauncherPrivate::doReportError(const QString &message, QProcess::ProcessError error)
|
||||
{
|
||||
m_remoteErrorString = message;
|
||||
m_remoteError = error;
|
||||
m_success = false;
|
||||
emit q->reportError(message);
|
||||
emit q->error(error);
|
||||
}
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
@@ -74,7 +74,6 @@ signals:
|
||||
void processExited(int exitCode, QProcess::ExitStatus);
|
||||
void error(QProcess::ProcessError error);
|
||||
|
||||
void reportError(const QString &errorOutput);
|
||||
void finished(bool success);
|
||||
|
||||
private:
|
||||
|
@@ -1252,10 +1252,9 @@ void SimpleTargetRunner::doStart(const Runnable &runnable, const IDevice::ConstP
|
||||
|
||||
} else {
|
||||
|
||||
connect(&m_launcher, &ApplicationLauncher::reportError,
|
||||
this, [this](const QString &msg) {
|
||||
reportFailure(msg);
|
||||
});
|
||||
connect(&m_launcher, &ApplicationLauncher::error, this, [this] {
|
||||
reportFailure(m_launcher.errorString());
|
||||
});
|
||||
|
||||
connect(&m_launcher, &ApplicationLauncher::finished,
|
||||
this, [this] {
|
||||
|
Reference in New Issue
Block a user