Utils: Work around readAllStandardError() with QProcess::MergedChannels

Instead of relying QProcess to operate with MergedChannels, keep
the separate channels and merge inside QtcProcess.

Fixes: QTCREATORBUG-27196
Change-Id: I3039267fcd6d90f95f8212642e17049b87af1156
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2022-03-29 17:32:43 +02:00
parent 98a2600150
commit de1bef18e2
2 changed files with 18 additions and 13 deletions

View File

@@ -222,6 +222,12 @@ void CallerHandle::handleStarted(const StartedSignal *launcherSignal)
void CallerHandle::handleReadyRead(const ReadyReadSignal *launcherSignal)
{
QTC_ASSERT(isCalledFromCallersThread(), return);
if (m_setup->m_processChannelMode == QProcess::MergedChannels) {
m_stdout += launcherSignal->stdOut();
m_stdout += launcherSignal->stdErr();
if (!m_stdout.isEmpty())
emit readyReadStandardOutput();
} else {
if (m_setup->m_processChannelMode == QProcess::ForwardedOutputChannel
|| m_setup->m_processChannelMode == QProcess::ForwardedChannels) {
std::cout << launcherSignal->stdOut().constData() << std::flush;
@@ -238,6 +244,7 @@ void CallerHandle::handleReadyRead(const ReadyReadSignal *launcherSignal)
if (!m_stderr.isEmpty())
emit readyReadStandardError();
}
}
}
void CallerHandle::handleFinished(const FinishedSignal *launcherSignal)

View File

@@ -205,8 +205,6 @@ void LauncherSocketHandler::handleStartPacket()
process->setEnvironment(packet.env);
process->setWorkingDirectory(packet.workingDir);
// Forwarding is handled by the LauncherInterface
process->setProcessChannelMode(packet.processChannelMode == QProcess::MergedChannels
? QProcess::MergedChannels : QProcess::SeparateChannels);
process->setStandardInputFile(packet.standardInputFile);
ProcessStartHandler *handler = process->processStartHandler();
handler->setProcessMode(packet.processMode);