SshDeviceProcess: Don't buffer stdOut and stdErr

It's already being buffered inside remoteProcess.

Change-Id: I5fd90df600454563342aaf142d21df28a404d9ba
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2022-01-28 13:55:58 +01:00
parent f529ec492c
commit 773f8a5bbe
2 changed files with 4 additions and 30 deletions

View File

@@ -58,8 +58,6 @@ public:
QProcess::ExitStatus exitStatus = QProcess::NormalExit; QProcess::ExitStatus exitStatus = QProcess::NormalExit;
DeviceProcessSignalOperation::Ptr killOperation; DeviceProcessSignalOperation::Ptr killOperation;
QTimer killTimer; QTimer killTimer;
QByteArray stdOut;
QByteArray stdErr;
int exitCode = -1; int exitCode = -1;
enum State { Inactive, Connecting, Connected, ProcessRunning } state = Inactive; enum State { Inactive, Connecting, Connected, ProcessRunning } state = Inactive;
@@ -163,16 +161,12 @@ QString SshDeviceProcess::errorString() const
QByteArray SshDeviceProcess::readAllStandardOutput() QByteArray SshDeviceProcess::readAllStandardOutput()
{ {
const QByteArray data = d->stdOut; return d->remoteProcess.get() ? d->remoteProcess->readAllStandardOutput() : QByteArray();
d->stdOut.clear();
return data;
} }
QByteArray SshDeviceProcess::readAllStandardError() QByteArray SshDeviceProcess::readAllStandardError()
{ {
const QByteArray data = d->stdErr; return d->remoteProcess.get() ? d->remoteProcess->readAllStandardError() : QByteArray();
d->stdErr.clear();
return data;
} }
qint64 SshDeviceProcess::processId() const qint64 SshDeviceProcess::processId() const
@@ -203,9 +197,9 @@ void SshDeviceProcess::handleConnected()
connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::done, connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::done,
this, &SshDeviceProcess::handleProcessFinished); this, &SshDeviceProcess::handleProcessFinished);
connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::readyReadStandardOutput, connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::readyReadStandardOutput,
this, &SshDeviceProcess::handleStdout); this, &QtcProcess::readyReadStandardOutput);
connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::readyReadStandardError, connect(d->remoteProcess.get(), &QSsh::SshRemoteProcess::readyReadStandardError,
this, &SshDeviceProcess::handleStderr); this, &QtcProcess::readyReadStandardError);
d->remoteProcess->start(); d->remoteProcess->start();
} }
} }
@@ -254,24 +248,6 @@ void SshDeviceProcess::handleProcessFinished(const QString &error)
emit finished(); emit finished();
} }
void SshDeviceProcess::handleStdout()
{
QByteArray output = d->remoteProcess->readAllStandardOutput();
if (output.isEmpty())
return;
d->stdOut += output;
emit readyReadStandardOutput();
}
void SshDeviceProcess::handleStderr()
{
QByteArray output = d->remoteProcess->readAllStandardError();
if (output.isEmpty())
return;
d->stdErr += output;
emit readyReadStandardError();
}
void SshDeviceProcess::handleKillOperationFinished(const QString &errorMessage) void SshDeviceProcess::handleKillOperationFinished(const QString &errorMessage)
{ {
QTC_ASSERT(d->state == SshDeviceProcessPrivate::ProcessRunning, return); QTC_ASSERT(d->state == SshDeviceProcessPrivate::ProcessRunning, return);

View File

@@ -61,8 +61,6 @@ private:
void handleDisconnected(); void handleDisconnected();
void handleProcessStarted(); void handleProcessStarted();
void handleProcessFinished(const QString &error); void handleProcessFinished(const QString &error);
void handleStdout();
void handleStderr();
void handleKillOperationFinished(const QString &errorMessage); void handleKillOperationFinished(const QString &errorMessage);
void handleKillOperationTimeout(); void handleKillOperationTimeout();