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 <joerg.bornemann@qt.io>
This commit is contained in:
Amir Masoud Abdol 2023-06-19 10:43:50 +02:00
parent b2093aad39
commit cdcead0ab2

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