Skip to content

Commit e1b0798

Browse files
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.
1 parent fd0979d commit e1b0798

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)