From e1b07981b31ac9b04988d5cf294621d6b8f1687c Mon Sep 17 00:00:00 2001 From: pablomartin4btc Date: Thu, 31 Aug 2023 16:35:03 -0300 Subject: [PATCH] qml: Fix possible QSettings init failure on startup Moving bitcoin.cpp app setters before parsing command-line options; otherwise if invalid parameters are passed, QSetting initialization would fail and the corresponding error will be displayed on terminal. --- src/qml/bitcoin.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/qml/bitcoin.cpp b/src/qml/bitcoin.cpp index 10e8a959d0..d87386cbd5 100644 --- a/src/qml/bitcoin.cpp +++ b/src/qml/bitcoin.cpp @@ -164,6 +164,13 @@ int QmlGuiMain(int argc, char* argv[]) SetupEnvironment(); util::ThreadSetInternalName("main"); + // must be set before parsing command-line options; otherwise, + // if invalid parameters were passed, QSetting initialization would fail + // and the error will be displayed on terminal + app.setOrganizationName(QAPP_ORG_NAME); + app.setOrganizationDomain(QAPP_ORG_DOMAIN); + app.setApplicationName(QAPP_APP_NAME_DEFAULT); + /// Parse command-line options. We do this after qt in order to show an error if there are problems parsing these. SetupServerArgs(gArgs); SetupUIArgs(gArgs); @@ -173,12 +180,6 @@ int QmlGuiMain(int argc, char* argv[]) return EXIT_FAILURE; } - // must be set before OptionsModel is initialized or translations are loaded, - // as it is used to locate QSettings - app.setOrganizationName(QAPP_ORG_NAME); - app.setOrganizationDomain(QAPP_ORG_DOMAIN); - app.setApplicationName(QAPP_APP_NAME_DEFAULT); - /// Determine availability of data directory. if (!CheckDataDirOption(gArgs)) { InitError(strprintf(Untranslated("Specified data directory \"%s\" does not exist.\n"), gArgs.GetArg("-datadir", "")));