Merge multiple ready read signals into one

This minimizes the amount of readyRead() signals emitted.

Change-Id: Ibd2409d6f273a2781839a73220cf41e57a941e54
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2021-08-25 08:20:44 +02:00
parent 6f0c56b6fd
commit 5fe210c7db

View File

@@ -81,9 +81,13 @@ public:
, m_stdErr(stdErr) {} , m_stdErr(stdErr) {}
QByteArray stdOut() const { return m_stdOut; } QByteArray stdOut() const { return m_stdOut; }
QByteArray stdErr() const { return m_stdErr; } QByteArray stdErr() const { return m_stdErr; }
void mergeWith(ReadyReadSignal *newSignal) {
m_stdOut += newSignal->stdOut();
m_stdErr += newSignal->stdErr();
}
private: private:
const QByteArray m_stdOut; QByteArray m_stdOut;
const QByteArray m_stdErr; QByteArray m_stdErr;
}; };
class FinishedSignal : public LauncherSignal class FinishedSignal : public LauncherSignal
@@ -245,7 +249,16 @@ void CallerHandle::appendSignal(LauncherSignal *launcherSignal)
QMutexLocker locker(&m_mutex); QMutexLocker locker(&m_mutex);
QTC_ASSERT(isCalledFromLaunchersThread(), return); QTC_ASSERT(isCalledFromLaunchersThread(), return);
// TODO: merge ReadyRead signals into one. // Merge ReadyRead signals into one.
if (launcherSignal->signalType() == CallerHandle::SignalType::ReadyRead
&& !m_signals.isEmpty()
&& m_signals.last()->signalType() == CallerHandle::SignalType::ReadyRead) {
ReadyReadSignal *lastSignal = static_cast<ReadyReadSignal *>(m_signals.last());
ReadyReadSignal *newSignal = static_cast<ReadyReadSignal *>(launcherSignal);
lastSignal->mergeWith(newSignal);
delete newSignal;
return;
}
m_signals.append(launcherSignal); m_signals.append(launcherSignal);
} }