From 6adca44116d2107c33af6ca6fcbb79bdb87629df Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 22 Aug 2022 16:30:55 +0200 Subject: [PATCH] External Tools: Force console output for Qt based tools Depending on platform and configuration and where they are run from (terminal or not), Qt applications can send some output to a different output stream than stdout/err (like Windows debug stream, or Linux journald). This is a bit confusing because e.g. we capture that kind of output for user applications run in Qt Creator. By default prevent it with the corresponding environment variable. Can still be overridden by setting QT_LOGGING_TO_CONSOLE=0 if that really poses a problem. Fixes: QTCREATORBUG-27828 Change-Id: I7e3f9930b045fc887144753384ba246ecdc52d90 Reviewed-by: Reviewed-by: David Schulz Reviewed-by: Jarek Kobus --- src/plugins/coreplugin/externaltool.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/coreplugin/externaltool.cpp b/src/plugins/coreplugin/externaltool.cpp index d00d7e572bf..11be6adee7c 100644 --- a/src/plugins/coreplugin/externaltool.cpp +++ b/src/plugins/coreplugin/externaltool.cpp @@ -634,7 +634,11 @@ void ExternalToolRunner::run() m_process->setWorkingDirectory(m_resolvedWorkingDirectory); const CommandLine cmd{m_resolvedExecutable, m_resolvedArguments, CommandLine::Raw}; m_process->setCommand(cmd); - m_process->setEnvironment(m_resolvedEnvironment); + Environment env = m_resolvedEnvironment; + // force Qt to log to std streams, if it's not explicitly been set differently + if (!env.hasKey("QT_LOGGING_TO_CONSOLE")) + env.set("QT_LOGGING_TO_CONSOLE", "1"); + m_process->setEnvironment(env); const auto write = m_tool->outputHandling() == ExternalTool::ShowInPane ? QOverload::of(MessageManager::writeDisrupting) : QOverload::of(MessageManager::writeSilently);