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: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
Eike Ziller
2022-08-22 16:30:55 +02:00
parent b1fd3f6e33
commit 6adca44116

View File

@@ -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<const QString &>::of(MessageManager::writeDisrupting)
: QOverload<const QString &>::of(MessageManager::writeSilently);