LinuxProcessImpl: Buffer standard error until started() is emitted

Change-Id: I1ee469a918ff95eeeb5038a4c2021469c429a269
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Jarek Kobus
2022-05-04 13:09:22 +02:00
parent 441488dd52
commit e9fb604812
3 changed files with 26 additions and 4 deletions

View File

@@ -493,6 +493,11 @@ void SshProcessInterface::handleReadyReadStandardOutput(const QByteArray &output
emit readyRead(outputData, {});
}
void SshProcessInterface::handleReadyReadStandardError(const QByteArray &errorData)
{
emit readyRead({}, errorData);
}
void SshProcessInterface::emitStarted(qint64 processId)
{
d->m_processId = processId;
@@ -641,10 +646,20 @@ void LinuxProcessInterface::handleReadyReadStandardOutput(const QByteArray &outp
emitStarted(processId);
if (!m_output.isEmpty())
emit readyRead(m_output, {});
if (!m_output.isEmpty() || !m_error.isEmpty())
emit readyRead(m_output, m_error);
m_output.clear();
m_error.clear();
}
void LinuxProcessInterface::handleReadyReadStandardError(const QByteArray &errorData)
{
if (m_pidParsed) {
emit readyRead({}, errorData);
return;
}
m_error.append(errorData);
}
SshProcessInterfacePrivate::SshProcessInterfacePrivate(SshProcessInterface *sshInterface,
@@ -721,12 +736,16 @@ void SshProcessInterfacePrivate::handleDone()
void SshProcessInterfacePrivate::handleReadyReadStandardOutput()
{
q->handleReadyReadStandardOutput(m_process.readAllStandardOutput()); // by default emits signal. linux impl does custom parsing for processId and emits delayed start() - only when terminal is off
// By default emits signal. LinuxProcessImpl does custom parsing for processId
// and emits delayed start() - only when terminal is off.
q->handleReadyReadStandardOutput(m_process.readAllStandardOutput());
}
void SshProcessInterfacePrivate::handleReadyReadStandardError()
{
emit q->readyRead({}, m_process.readAllStandardError());
// By default emits signal. LinuxProcessImpl buffers the error channel until
// it emits delayed start() - only when terminal is off.
q->handleReadyReadStandardError(m_process.readAllStandardError());
}
void SshProcessInterfacePrivate::clearForStart()

View File

@@ -45,10 +45,12 @@ private:
void handleStarted(qint64 processId) final;
void handleReadyReadStandardOutput(const QByteArray &outputData) final;
void handleReadyReadStandardError(const QByteArray &errorData) final;
QString fullCommandLine(const Utils::CommandLine &commandLine) const final;
QByteArray m_output;
QByteArray m_error;
bool m_pidParsed = false;
};

View File

@@ -51,6 +51,7 @@ protected:
private:
virtual void handleStarted(qint64 processId);
virtual void handleReadyReadStandardOutput(const QByteArray &outputData);
virtual void handleReadyReadStandardError(const QByteArray &errorData);
virtual QString fullCommandLine(const Utils::CommandLine &commandLine) const = 0;