Skip to content

Commit

Permalink
Merge #360: Fix QSettings initialization failure on startup when pars…
Browse files Browse the repository at this point in the history
…ing invalid arguments

e1b0798 qml: Fix possible QSettings init failure on startup (pablomartin4btc)

Pull request description:

  This fixes #361.

  After applying the fix, no QML source code errors should be displayed on the terminal:

  ![image](https://github.com/bitcoin-core/gui-qml/assets/110166421/c6acc58d-a08d-48cd-836d-591c074e6001)

ACKs for top commit:
  D33r-Gee:
    tACK e1b0798 on WSL Ubuntu 22.04 on `signet` no issues detected
  johnny9:
    ACK e1b0798

Tree-SHA512: ef7bc95782127df7f2f541eedab69c71fd6c1ee2e9d516a3003923b4e9869543c05f26297db5b945f2e40852e8b6cec4d3edc653805cfcd85254b922beb4703b
  • Loading branch information
hebasto committed Jan 14, 2024
2 parents 533a9fc + e1b0798 commit 58f8d44
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 58f8d44

Please sign in to comment.