From b10df4c1b3cdb0d2d9c36a0655af95085abe615e Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Fri, 23 Feb 2024 17:01:58 +0100 Subject: [PATCH] ProjectExplorer: Show full lines during compilation Especially on Windows with VC2022 & Ninja, the output would often display lines that ended in the middle until the next batch of output was added. This patch uses the Process facilities to only show full lines. Change-Id: I38fcb2e8cb115637d15181b39374c533db150c1a Reviewed-by: Reviewed-by: David Schulz --- .../projectexplorer/abstractprocessstep.cpp | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/plugins/projectexplorer/abstractprocessstep.cpp b/src/plugins/projectexplorer/abstractprocessstep.cpp index 84a31135790..547599bc9d6 100644 --- a/src/plugins/projectexplorer/abstractprocessstep.cpp +++ b/src/plugins/projectexplorer/abstractprocessstep.cpp @@ -79,8 +79,6 @@ public: std::function m_environmentModifier; bool m_ignoreReturnValue = false; bool m_lowPriority = false; - std::unique_ptr stdOutDecoder; - std::unique_ptr stdErrDecoder; OutputFormatter *outputFormatter = nullptr; }; @@ -146,9 +144,6 @@ bool AbstractProcessStep::init() if (!setupProcessParameters(processParameters())) return false; - d->stdOutDecoder = std::make_unique(buildEnvironment().hasKey("VSLANG") - ? QTextCodec::codecForName("UTF-8") : QTextCodec::codecForLocale()); - d->stdErrDecoder = std::make_unique(QTextCodec::codecForLocale()); return true; } @@ -197,14 +192,18 @@ bool AbstractProcessStep::setupProcess(Process &process) if (d->m_lowPriority && ProjectExplorerPlugin::projectExplorerSettings().lowBuildPriority) process.setLowPriority(); - connect(&process, &Process::readyReadStandardOutput, this, [this, &process] { - emit addOutput(d->stdOutDecoder->toUnicode(process.readAllRawStandardOutput()), - OutputFormat::Stdout, DontAppendNewline); + process.setStdOutCodec(buildEnvironment().hasKey("VSLANG") + ? QTextCodec::codecForName("UTF-8") : QTextCodec::codecForLocale()); + process.setStdErrCodec(QTextCodec::codecForLocale()); + + process.setStdOutLineCallback([this](const QString &s){ + emit addOutput(s, OutputFormat::Stdout, DontAppendNewline); }); - connect(&process, &Process::readyReadStandardError, this, [this, &process] { - emit addOutput(d->stdErrDecoder->toUnicode(process.readAllRawStandardError()), - OutputFormat::Stderr, DontAppendNewline); + + process.setStdErrLineCallback([this](const QString &s){ + emit addOutput(s, OutputFormat::Stderr, DontAppendNewline); }); + connect(&process, &Process::started, this, [this] { ProcessParameters *params = d->m_displayedParams; emit addOutput(Tr::tr("Starting: \"%1\" %2")