forked from qt-creator/qt-creator
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:
@@ -77,10 +77,8 @@ class DeviceApplicationObserver : public ApplicationLauncher
|
||||
public:
|
||||
DeviceApplicationObserver(const IDevice::ConstPtr &device, const CommandLine &command)
|
||||
{
|
||||
connect(&m_appRunner, &ApplicationLauncher::remoteStdout, this,
|
||||
&DeviceApplicationObserver::handleStdout);
|
||||
connect(&m_appRunner, &ApplicationLauncher::remoteStderr, this,
|
||||
&DeviceApplicationObserver::handleStderr);
|
||||
connect(&m_appRunner, &ApplicationLauncher::appendMessage, this,
|
||||
&DeviceApplicationObserver::handleAppendMessage);
|
||||
connect(&m_appRunner, &ApplicationLauncher::reportError, this,
|
||||
&DeviceApplicationObserver::handleError);
|
||||
connect(&m_appRunner, &ApplicationLauncher::finished, this,
|
||||
@@ -97,8 +95,13 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void handleStdout(const QString &data) { m_stdout += data; }
|
||||
void handleStderr(const QString &data) { m_stderr += data; }
|
||||
void handleAppendMessage(const QString &data, Utils::OutputFormat format)
|
||||
{
|
||||
if (format == Utils::StdOutFormat)
|
||||
m_stdout += data;
|
||||
else if (format == Utils::StdErrFormat)
|
||||
m_stderr += data;
|
||||
}
|
||||
void handleError(const QString &message) { m_error = message; }
|
||||
|
||||
void handleFinished(bool success)
|
||||
|
@@ -61,11 +61,6 @@ public:
|
||||
this, &RunWorker::reportStopped);
|
||||
connect(&m_launcher, &ApplicationLauncher::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->setUseGdbServer(useGdbServer || usePerf);
|
||||
m_portsGatherer->setUseQmlServer(useQmlServer);
|
||||
|
@@ -78,29 +78,18 @@ void QdbStopApplicationService::handleProcessFinished(bool success)
|
||||
stopDeployment();
|
||||
}
|
||||
|
||||
void QdbStopApplicationService::handleStderr(const QString &output)
|
||||
void QdbStopApplicationService::handleAppendMessage(const QString &message, Utils::OutputFormat format)
|
||||
{
|
||||
d->errorOutput.append(output);
|
||||
}
|
||||
|
||||
void QdbStopApplicationService::handleStdout(const QString &output)
|
||||
{
|
||||
emit stdOutData(output);
|
||||
}
|
||||
|
||||
void QdbStopApplicationService::handleAppendMessage(const QString &message)
|
||||
{
|
||||
emit stdOutData(message);
|
||||
if (format == Utils::StdErrFormat)
|
||||
d->errorOutput.append(message);
|
||||
else
|
||||
emit stdOutData(message);
|
||||
}
|
||||
|
||||
void QdbStopApplicationService::doDeploy()
|
||||
{
|
||||
connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::reportError,
|
||||
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,
|
||||
this, &QdbStopApplicationService::handleProcessFinished);
|
||||
connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::appendMessage,
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <remotelinux/abstractremotelinuxdeployservice.h>
|
||||
#include <utils/outputformat.h>
|
||||
|
||||
namespace Qdb {
|
||||
namespace Internal {
|
||||
@@ -41,9 +42,7 @@ public:
|
||||
|
||||
private:
|
||||
void handleProcessFinished(bool success);
|
||||
void handleStderr(const QString &output);
|
||||
void handleStdout(const QString &output);
|
||||
void handleAppendMessage(const QString &message);
|
||||
void handleAppendMessage(const QString &message, Utils::OutputFormat format);
|
||||
|
||||
bool isDeploymentNecessary() const final { return true; }
|
||||
void doDeviceSetup() final { handleDeviceSetupDone(true); }
|
||||
|
@@ -492,14 +492,14 @@ void ApplicationLauncherPrivate::handleRemoteStdout()
|
||||
{
|
||||
QTC_ASSERT(m_state == Run, return);
|
||||
const QByteArray output = m_deviceProcess->readAllStandardOutput();
|
||||
emit q->remoteStdout(QString::fromUtf8(output));
|
||||
emit q->appendMessage(QString::fromUtf8(output), Utils::StdOutFormat, false);
|
||||
}
|
||||
|
||||
void ApplicationLauncherPrivate::handleRemoteStderr()
|
||||
{
|
||||
QTC_ASSERT(m_state == Run, return);
|
||||
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)
|
||||
|
@@ -74,8 +74,6 @@ signals:
|
||||
void processExited(int exitCode, QProcess::ExitStatus);
|
||||
void error(QProcess::ProcessError error);
|
||||
|
||||
void remoteStdout(const QString &output);
|
||||
void remoteStderr(const QString &output);
|
||||
void reportError(const QString &errorOutput);
|
||||
void remoteProcessStarted();
|
||||
void finished(bool success);
|
||||
|
@@ -1257,16 +1257,6 @@ void SimpleTargetRunner::doStart(const Runnable &runnable, const IDevice::ConstP
|
||||
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,
|
||||
this, [this] {
|
||||
m_launcher.disconnect(this);
|
||||
@@ -1290,10 +1280,7 @@ void SimpleTargetRunner::doStart(const Runnable &runnable, const IDevice::ConstP
|
||||
reportStarted();
|
||||
});
|
||||
|
||||
connect(&m_launcher, &ApplicationLauncher::appendMessage,
|
||||
this, [this](const QString &progressString, Utils::OutputFormat format) {
|
||||
appendMessage(progressString, format);
|
||||
});
|
||||
connect(&m_launcher, &ApplicationLauncher::appendMessage, this, &RunWorker::appendMessage);
|
||||
|
||||
m_launcher.start(runnable, device);
|
||||
}
|
||||
|
@@ -48,13 +48,10 @@ public:
|
||||
|
||||
bool run();
|
||||
|
||||
void handleRemoteStderr(const QString &b);
|
||||
void handleRemoteStdout(const QString &b);
|
||||
|
||||
void closed(bool success);
|
||||
void localProcessStarted();
|
||||
void remoteProcessStarted();
|
||||
void findPidOutputReceived(const QString &out);
|
||||
void findPidOutputReceived(const QString &out, Utils::OutputFormat format);
|
||||
|
||||
ValgrindRunner *q;
|
||||
Runnable m_debuggee;
|
||||
@@ -128,10 +125,6 @@ bool ValgrindRunner::Private::run()
|
||||
connect(&m_valgrindProcess, &ApplicationLauncher::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,
|
||||
this, &ValgrindRunner::Private::remoteProcessStarted);
|
||||
|
||||
@@ -161,18 +154,6 @@ bool ValgrindRunner::Private::run()
|
||||
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()
|
||||
{
|
||||
qint64 pid = m_valgrindProcess.applicationPID().pid();
|
||||
@@ -207,19 +188,21 @@ void ValgrindRunner::Private::remoteProcessStarted()
|
||||
"\"").arg(proc, m_debuggee.command.executable().fileName(), procEscaped));
|
||||
|
||||
// m_remote.m_findPID = m_remote.m_connection->createRemoteProcess(cmd.toUtf8());
|
||||
connect(&m_findPID, &ApplicationLauncher::remoteStderr,
|
||||
this, &ValgrindRunner::Private::handleRemoteStderr);
|
||||
connect(&m_findPID, &ApplicationLauncher::remoteStdout,
|
||||
connect(&m_findPID, &ApplicationLauncher::appendMessage,
|
||||
this, &ValgrindRunner::Private::findPidOutputReceived);
|
||||
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())
|
||||
return;
|
||||
bool ok;
|
||||
qint64 pid = out.trimmed().toLongLong(&ok);
|
||||
const qint64 pid = out.trimmed().toLongLong(&ok);
|
||||
if (!ok) {
|
||||
// m_remote.m_errorString = tr("Could not determine remote PID.");
|
||||
// emit ValgrindRunner::Private::error(QProcess::FailedToStart);
|
||||
|
Reference in New Issue
Block a user