QtcProcess: Be idle when incoming data is empty

Don't forward and flush empty data

Change-Id: Idb153695d7eb62905c000b70efdfb0c68f0df9ad
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2022-06-23 11:22:30 +02:00
parent 44aea533f8
commit 9fde8511e2

View File

@@ -1983,21 +1983,24 @@ void QtcProcessPrivate::handleReadyRead(const QByteArray &outputData, const QByt
m_hangTimerCount = 0; m_hangTimerCount = 0;
// TODO: store a copy of m_processChannelMode on start()? Currently we assert that state // TODO: store a copy of m_processChannelMode on start()? Currently we assert that state
// is NotRunning when setting the process channel mode. // is NotRunning when setting the process channel mode.
if (m_process->m_setup.m_processChannelMode == QProcess::ForwardedOutputChannel
|| m_process->m_setup.m_processChannelMode == QProcess::ForwardedChannels) { if (!outputData.isEmpty()) {
std::cout << outputData.constData() << std::flush; if (m_process->m_setup.m_processChannelMode == QProcess::ForwardedOutputChannel
} else { || m_process->m_setup.m_processChannelMode == QProcess::ForwardedChannels) {
m_stdOut.append(outputData); std::cout << outputData.constData() << std::flush;
if (!outputData.isEmpty()) } else {
m_stdOut.append(outputData);
emitReadyReadStandardOutput(); emitReadyReadStandardOutput();
}
} }
if (m_process->m_setup.m_processChannelMode == QProcess::ForwardedErrorChannel if (!errorData.isEmpty()) {
|| m_process->m_setup.m_processChannelMode == QProcess::ForwardedChannels) { if (m_process->m_setup.m_processChannelMode == QProcess::ForwardedErrorChannel
std::cerr << errorData.constData() << std::flush; || m_process->m_setup.m_processChannelMode == QProcess::ForwardedChannels) {
} else { std::cerr << errorData.constData() << std::flush;
m_stdErr.append(errorData); } else {
if (!errorData.isEmpty()) m_stdErr.append(errorData);
emitReadyReadStandardError(); emitReadyReadStandardError();
}
} }
} }