From cdcead0ab2a83b268e6cf1109b9af5f0abc31728 Mon Sep 17 00:00:00 2001 From: Amir Masoud Abdol Date: Mon, 19 Jun 2023 10:43:50 +0200 Subject: [PATCH] Introduce QT_COMMAND_LINE_PARSER_NO_GUI_MESSAGE_BOXES environment var Add an environment variable to be able to stop QCommandLinerParser from showing GUI message boxes when console is not available. Pick-to: 6.5.2 6.5 6.6 Task-number: QTBUG-114530 Change-Id: I52500a2177894bc0bf2d20f9723ce3e8fe87420f Reviewed-by: Joerg Bornemann --- src/corelib/tools/qcommandlineparser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp index c0b7c81fd6e..c1581a27212 100644 --- a/src/corelib/tools/qcommandlineparser.cpp +++ b/src/corelib/tools/qcommandlineparser.cpp @@ -521,7 +521,8 @@ enum MessageType { UsageMessage, ErrorMessage }; // or we are run with redirected handles (for example, by QProcess). static inline bool displayMessageBox() { - if (GetConsoleWindow()) + if (GetConsoleWindow() + || qEnvironmentVariableIsSet("QT_COMMAND_LINE_PARSER_NO_GUI_MESSAGE_BOXES")) return false; STARTUPINFO startupInfo; startupInfo.cb = sizeof(STARTUPINFO);