Uniform ApplicationLauncher API: get rid of remoteStderr/out()

Use existing appendMessage() for this purpose either with
StdErrFormat for remoteStderr() or with StdOutFormat for remoteStdout().
In case when device process is used in ApplicationLauncher
no appendMessage() was emitted so far with StdErrFormat or StdOutFormat.

Change-Id: I2f6603aaf28113fea2a8bb6bd1738320cc39be75
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2021-11-09 16:00:18 +01:00
parent 9739ded573
commit d14e68eac2
8 changed files with 27 additions and 73 deletions

View File

@@ -77,10 +77,8 @@ class DeviceApplicationObserver : public ApplicationLauncher
public: public:
DeviceApplicationObserver(const IDevice::ConstPtr &device, const CommandLine &command) DeviceApplicationObserver(const IDevice::ConstPtr &device, const CommandLine &command)
{ {
connect(&m_appRunner, &ApplicationLauncher::remoteStdout, this, connect(&m_appRunner, &ApplicationLauncher::appendMessage, this,
&DeviceApplicationObserver::handleStdout); &DeviceApplicationObserver::handleAppendMessage);
connect(&m_appRunner, &ApplicationLauncher::remoteStderr, this,
&DeviceApplicationObserver::handleStderr);
connect(&m_appRunner, &ApplicationLauncher::reportError, this, connect(&m_appRunner, &ApplicationLauncher::reportError, this,
&DeviceApplicationObserver::handleError); &DeviceApplicationObserver::handleError);
connect(&m_appRunner, &ApplicationLauncher::finished, this, connect(&m_appRunner, &ApplicationLauncher::finished, this,
@@ -97,8 +95,13 @@ public:
} }
private: private:
void handleStdout(const QString &data) { m_stdout += data; } void handleAppendMessage(const QString &data, Utils::OutputFormat format)
void handleStderr(const QString &data) { m_stderr += data; } {
if (format == Utils::StdOutFormat)
m_stdout += data;
else if (format == Utils::StdErrFormat)
m_stderr += data;
}
void handleError(const QString &message) { m_error = message; } void handleError(const QString &message) { m_error = message; }
void handleFinished(bool success) void handleFinished(bool success)

View File

@@ -61,11 +61,6 @@ public:
this, &RunWorker::reportStopped); this, &RunWorker::reportStopped);
connect(&m_launcher, &ApplicationLauncher::appendMessage, connect(&m_launcher, &ApplicationLauncher::appendMessage,
this, &RunWorker::appendMessage); this, &RunWorker::appendMessage);
connect(&m_launcher, &ApplicationLauncher::remoteStdout,
this, [this](const QString &out) { appendMessage(out, StdOutFormat); });
connect(&m_launcher, &ApplicationLauncher::remoteStderr,
this, [this](const QString &out) { appendMessage(out, StdErrFormat); });
m_portsGatherer = new DebugServerPortsGatherer(runControl); m_portsGatherer = new DebugServerPortsGatherer(runControl);
m_portsGatherer->setUseGdbServer(useGdbServer || usePerf); m_portsGatherer->setUseGdbServer(useGdbServer || usePerf);
m_portsGatherer->setUseQmlServer(useQmlServer); m_portsGatherer->setUseQmlServer(useQmlServer);

View File

@@ -78,29 +78,18 @@ void QdbStopApplicationService::handleProcessFinished(bool success)
stopDeployment(); stopDeployment();
} }
void QdbStopApplicationService::handleStderr(const QString &output) void QdbStopApplicationService::handleAppendMessage(const QString &message, Utils::OutputFormat format)
{ {
d->errorOutput.append(output); if (format == Utils::StdErrFormat)
} d->errorOutput.append(message);
else
void QdbStopApplicationService::handleStdout(const QString &output) emit stdOutData(message);
{
emit stdOutData(output);
}
void QdbStopApplicationService::handleAppendMessage(const QString &message)
{
emit stdOutData(message);
} }
void QdbStopApplicationService::doDeploy() void QdbStopApplicationService::doDeploy()
{ {
connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::reportError, connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::reportError,
this, &QdbStopApplicationService::stdErrData); this, &QdbStopApplicationService::stdErrData);
connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::remoteStderr,
this, &QdbStopApplicationService::handleStderr);
connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::remoteStdout,
this, &QdbStopApplicationService::handleStdout);
connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::finished, connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::finished,
this, &QdbStopApplicationService::handleProcessFinished); this, &QdbStopApplicationService::handleProcessFinished);
connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::appendMessage, connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::appendMessage,

View File

@@ -26,6 +26,7 @@
#pragma once #pragma once
#include <remotelinux/abstractremotelinuxdeployservice.h> #include <remotelinux/abstractremotelinuxdeployservice.h>
#include <utils/outputformat.h>
namespace Qdb { namespace Qdb {
namespace Internal { namespace Internal {
@@ -41,9 +42,7 @@ public:
private: private:
void handleProcessFinished(bool success); void handleProcessFinished(bool success);
void handleStderr(const QString &output); void handleAppendMessage(const QString &message, Utils::OutputFormat format);
void handleStdout(const QString &output);
void handleAppendMessage(const QString &message);
bool isDeploymentNecessary() const final { return true; } bool isDeploymentNecessary() const final { return true; }
void doDeviceSetup() final { handleDeviceSetupDone(true); } void doDeviceSetup() final { handleDeviceSetupDone(true); }

View File

@@ -492,14 +492,14 @@ void ApplicationLauncherPrivate::handleRemoteStdout()
{ {
QTC_ASSERT(m_state == Run, return); QTC_ASSERT(m_state == Run, return);
const QByteArray output = m_deviceProcess->readAllStandardOutput(); const QByteArray output = m_deviceProcess->readAllStandardOutput();
emit q->remoteStdout(QString::fromUtf8(output)); emit q->appendMessage(QString::fromUtf8(output), Utils::StdOutFormat, false);
} }
void ApplicationLauncherPrivate::handleRemoteStderr() void ApplicationLauncherPrivate::handleRemoteStderr()
{ {
QTC_ASSERT(m_state == Run, return); QTC_ASSERT(m_state == Run, return);
const QByteArray output = m_deviceProcess->readAllStandardError(); const QByteArray output = m_deviceProcess->readAllStandardError();
emit q->remoteStderr(QString::fromUtf8(output)); emit q->appendMessage(QString::fromUtf8(output), Utils::StdErrFormat, false);
} }
void ApplicationLauncherPrivate::doReportError(const QString &message) void ApplicationLauncherPrivate::doReportError(const QString &message)

View File

@@ -74,8 +74,6 @@ signals:
void processExited(int exitCode, QProcess::ExitStatus); void processExited(int exitCode, QProcess::ExitStatus);
void error(QProcess::ProcessError error); void error(QProcess::ProcessError error);
void remoteStdout(const QString &output);
void remoteStderr(const QString &output);
void reportError(const QString &errorOutput); void reportError(const QString &errorOutput);
void remoteProcessStarted(); void remoteProcessStarted();
void finished(bool success); void finished(bool success);

View File

@@ -1257,16 +1257,6 @@ void SimpleTargetRunner::doStart(const Runnable &runnable, const IDevice::ConstP
reportFailure(msg); reportFailure(msg);
}); });
connect(&m_launcher, &ApplicationLauncher::remoteStderr,
this, [this](const QString &output) {
appendMessage(output, Utils::StdErrFormat, false);
});
connect(&m_launcher, &ApplicationLauncher::remoteStdout,
this, [this](const QString &output) {
appendMessage(output, Utils::StdOutFormat, false);
});
connect(&m_launcher, &ApplicationLauncher::finished, connect(&m_launcher, &ApplicationLauncher::finished,
this, [this] { this, [this] {
m_launcher.disconnect(this); m_launcher.disconnect(this);
@@ -1290,10 +1280,7 @@ void SimpleTargetRunner::doStart(const Runnable &runnable, const IDevice::ConstP
reportStarted(); reportStarted();
}); });
connect(&m_launcher, &ApplicationLauncher::appendMessage, connect(&m_launcher, &ApplicationLauncher::appendMessage, this, &RunWorker::appendMessage);
this, [this](const QString &progressString, Utils::OutputFormat format) {
appendMessage(progressString, format);
});
m_launcher.start(runnable, device); m_launcher.start(runnable, device);
} }

View File

@@ -48,13 +48,10 @@ public:
bool run(); bool run();
void handleRemoteStderr(const QString &b);
void handleRemoteStdout(const QString &b);
void closed(bool success); void closed(bool success);
void localProcessStarted(); void localProcessStarted();
void remoteProcessStarted(); void remoteProcessStarted();
void findPidOutputReceived(const QString &out); void findPidOutputReceived(const QString &out, Utils::OutputFormat format);
ValgrindRunner *q; ValgrindRunner *q;
Runnable m_debuggee; Runnable m_debuggee;
@@ -128,10 +125,6 @@ bool ValgrindRunner::Private::run()
connect(&m_valgrindProcess, &ApplicationLauncher::finished, connect(&m_valgrindProcess, &ApplicationLauncher::finished,
q, &ValgrindRunner::finished); q, &ValgrindRunner::finished);
connect(&m_valgrindProcess, &ApplicationLauncher::remoteStderr,
this, &ValgrindRunner::Private::handleRemoteStderr);
connect(&m_valgrindProcess, &ApplicationLauncher::remoteStdout,
this, &ValgrindRunner::Private::handleRemoteStdout);
connect(&m_valgrindProcess, &ApplicationLauncher::remoteProcessStarted, connect(&m_valgrindProcess, &ApplicationLauncher::remoteProcessStarted,
this, &ValgrindRunner::Private::remoteProcessStarted); this, &ValgrindRunner::Private::remoteProcessStarted);
@@ -161,18 +154,6 @@ bool ValgrindRunner::Private::run()
return true; return true;
} }
void ValgrindRunner::Private::handleRemoteStderr(const QString &b)
{
if (!b.isEmpty())
emit q->processOutputReceived(b, Utils::StdErrFormat);
}
void ValgrindRunner::Private::handleRemoteStdout(const QString &b)
{
if (!b.isEmpty())
emit q->processOutputReceived(b, Utils::StdOutFormat);
}
void ValgrindRunner::Private::localProcessStarted() void ValgrindRunner::Private::localProcessStarted()
{ {
qint64 pid = m_valgrindProcess.applicationPID().pid(); qint64 pid = m_valgrindProcess.applicationPID().pid();
@@ -207,19 +188,21 @@ void ValgrindRunner::Private::remoteProcessStarted()
"\"").arg(proc, m_debuggee.command.executable().fileName(), procEscaped)); "\"").arg(proc, m_debuggee.command.executable().fileName(), procEscaped));
// m_remote.m_findPID = m_remote.m_connection->createRemoteProcess(cmd.toUtf8()); // m_remote.m_findPID = m_remote.m_connection->createRemoteProcess(cmd.toUtf8());
connect(&m_findPID, &ApplicationLauncher::remoteStderr, connect(&m_findPID, &ApplicationLauncher::appendMessage,
this, &ValgrindRunner::Private::handleRemoteStderr);
connect(&m_findPID, &ApplicationLauncher::remoteStdout,
this, &ValgrindRunner::Private::findPidOutputReceived); this, &ValgrindRunner::Private::findPidOutputReceived);
m_findPID.start(findPid, m_device); m_findPID.start(findPid, m_device);
} }
void ValgrindRunner::Private::findPidOutputReceived(const QString &out) void ValgrindRunner::Private::findPidOutputReceived(const QString &out, Utils::OutputFormat format)
{ {
if (format != Utils::StdOutFormat) {
emit q->processOutputReceived(out, format);
return;
}
if (out.isEmpty()) if (out.isEmpty())
return; return;
bool ok; bool ok;
qint64 pid = out.trimmed().toLongLong(&ok); const qint64 pid = out.trimmed().toLongLong(&ok);
if (!ok) { if (!ok) {
// m_remote.m_errorString = tr("Could not determine remote PID."); // m_remote.m_errorString = tr("Could not determine remote PID.");
// emit ValgrindRunner::Private::error(QProcess::FailedToStart); // emit ValgrindRunner::Private::error(QProcess::FailedToStart);