summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2023-01-30 09:59:22 +0100
committerPeter Varga <pvarga@inf.u-szeged.hu>2023-01-30 12:14:02 +0100
commitc38b9e66e01b7f50948c20f32823f5cbff929ac6 (patch)
treeb643f819ff7b45ca768e2395f084069b5245a751 /src
parent98fc7baa11743562543651f0d756bfd1c5add814 (diff)
downloadqtwebengine-c38b9e66e01b7f50948c20f32823f5cbff929ac6.tar.gz
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 <michal.klocek@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/core/web_engine_context.cpp15
1 files changed, 6 insertions, 9 deletions
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;
}