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.

Task-number: QTBUG-114530
Change-Id: I52500a2177894bc0bf2d20f9723ce3e8fe87420f
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit cdcead0ab2a83b268e6cf1109b9af5f0abc31728)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Amir Masoud Abdol 2023-06-19 10:43:50 +02:00 committed by Qt Cherry-pick Bot
parent d0262b4f95
commit c9207ef38f

View File

@ -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);