Skip to content

Commit 58f8d44

Browse files
committed
Merge #360: Fix QSettings initialization failure on startup when parsing 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
2 parents 533a9fc + e1b0798 commit 58f8d44

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/qml/bitcoin.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,13 @@ int QmlGuiMain(int argc, char* argv[])
164164
SetupEnvironment();
165165
util::ThreadSetInternalName("main");
166166

167+
// must be set before parsing command-line options; otherwise,
168+
// if invalid parameters were passed, QSetting initialization would fail
169+
// and the error will be displayed on terminal
170+
app.setOrganizationName(QAPP_ORG_NAME);
171+
app.setOrganizationDomain(QAPP_ORG_DOMAIN);
172+
app.setApplicationName(QAPP_APP_NAME_DEFAULT);
173+
167174
/// Parse command-line options. We do this after qt in order to show an error if there are problems parsing these.
168175
SetupServerArgs(gArgs);
169176
SetupUIArgs(gArgs);
@@ -173,12 +180,6 @@ int QmlGuiMain(int argc, char* argv[])
173180
return EXIT_FAILURE;
174181
}
175182

176-
// must be set before OptionsModel is initialized or translations are loaded,
177-
// as it is used to locate QSettings
178-
app.setOrganizationName(QAPP_ORG_NAME);
179-
app.setOrganizationDomain(QAPP_ORG_DOMAIN);
180-
app.setApplicationName(QAPP_APP_NAME_DEFAULT);
181-
182183
/// Determine availability of data directory.
183184
if (!CheckDataDirOption(gArgs)) {
184185
InitError(strprintf(Untranslated("Specified data directory \"%s\" does not exist.\n"), gArgs.GetArg("-datadir", "")));

0 commit comments

Comments
 (0)