From c38b9e66e01b7f50948c20f32823f5cbff929ac6 Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Mon, 30 Jan 2023 09:59:22 +0100 Subject: Yield fatal error for empty command-line arguments Resolving TODO, the corresponding Active Qt issue has been fixed. This amends commit 614d6639b875f53b21eaabd2d5928b84b59af707 Pick-to: 6.5 Change-Id: If0144af83cd1d512b151ce82a38e47b4811fbfa8 Taks-number: QTBUG-110157 Taks-number: QTBUG-110158 Reviewed-by: Michal Klocek --- src/core/web_engine_context.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 67d015e48..50dcde636 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -845,8 +845,13 @@ base::CommandLine *WebEngineContext::initCommandLine(bool &useEmbeddedSwitches, if (!base::CommandLine::CreateEmpty()) qFatal("base::CommandLine has been initialized unexpectedly."); - base::CommandLine *parsedCommandLine = base::CommandLine::ForCurrentProcess(); QStringList appArgs = QCoreApplication::arguments(); + if (appArgs.empty()) { + qFatal("Argument list is empty, the program name is not passed to QCoreApplication. " + "base::CommandLine cannot be properly initialized."); + } + + base::CommandLine *parsedCommandLine = base::CommandLine::ForCurrentProcess(); if (qEnvironmentVariableIsSet(kChromiumFlagsEnv)) { appArgs = appArgs.mid(0, 1); // Take application name and drop the rest appArgs.append(parseEnvCommandLine(qEnvironmentVariable(kChromiumFlagsEnv))); @@ -879,14 +884,6 @@ base::CommandLine *WebEngineContext::initCommandLine(bool &useEmbeddedSwitches, #endif parsedCommandLine->InitFromArgv(argv); - if (QCoreApplication::arguments().empty()) { - // TODO: Replace this qWarning with a qFatal at the beginning of the function - // when the corresponding Active Qt issue gets fixed: QTBUG-110158. - qWarning("Argument list is empty, the program name is not passed to QCoreApplication. " - "Command line arguments might be ignored. Unexpected behavior may occur."); - Q_ASSERT(false); - } - return parsedCommandLine; } -- cgit v1.2.1