Skip to content

Commit

Permalink
qml: Fix possible QSettings init failure on startup
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pablomartin4btc committed Sep 8, 2023
1 parent fd0979d commit e1b0798
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/qml/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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", "")));
Expand Down

0 comments on commit e1b0798

Please sign in to comment.