-
Notifications
You must be signed in to change notification settings - Fork 294
Unify bitcoin-qt and bitcoind persistent settings #602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
284f339
a7ef6d5
1dc4fc2
d2ada6e
a09e3b7
f067e19
9a016a3
504b06b
99ccc02
e47c6c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
GUI changes | ||
----------- | ||
|
||
Configuration changes made in the bitcoin GUI (such as the pruning setting, | ||
proxy settings, UPNP preferences) are now saved to `<datadir>/settings.json` | ||
file rather than to the Qt settings backend (windows registry or unix desktop | ||
config files), so these settings will now apply to bitcoind, instead of being | ||
ignored. | ||
|
||
Also, the interaction between GUI settings and `bitcoin.conf` settings is | ||
simplified. Settings from `bitcoin.conf` are now displayed normally in the GUI | ||
settings dialog, instead of in a separate warning message ("Options set in this | ||
dialog are overridden by the configuration file: -setting=value"). And these | ||
settings can now be edited because `settings.json` values take precedence over | ||
`bitcoin.conf` values. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -259,9 +259,26 @@ void BitcoinApplication::createPaymentServer() | |
} | ||
#endif | ||
|
||
void BitcoinApplication::createOptionsModel(bool resetSettings) | ||
bool BitcoinApplication::createOptionsModel(bool resetSettings) | ||
{ | ||
optionsModel = new OptionsModel(node(), this, resetSettings); | ||
optionsModel = new OptionsModel(node(), this); | ||
if (resetSettings) { | ||
optionsModel->Reset(); | ||
} | ||
bilingual_str error; | ||
if (!optionsModel->Init(error)) { | ||
fs::path settings_path; | ||
if (gArgs.GetSettingsPath(&settings_path)) { | ||
error += Untranslated("\n"); | ||
std::string quoted_path = strprintf("%s", fs::quoted(fs::PathToString(settings_path))); | ||
error.original += strprintf("Settings file %s might be corrupt or invalid.", quoted_path); | ||
error.translated += tr("Settings file %1 might be corrupt or invalid.").arg(QString::fromStdString(quoted_path)).toStdString(); | ||
} | ||
InitError(error); | ||
QMessageBox::critical(nullptr, PACKAGE_NAME, QString::fromStdString(error.translated)); | ||
Comment on lines
+277
to
+278
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In 6afa080: This is going to open two dialogs, one after the other. Is that intended? First one: Second one: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. re: #602 (comment) This wouldn't be intended, but I don't think this problem happens in practice, or at least I can't reproduce it. I can trigger the error with {
"dbcache": [
]
} In this case, InitError just logs an error without creating a message box because There is a bunch of other in code the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah ok, that was a bit misleading when I read it. Make sense, thanks 👌🏼. Agree about the possible future simplification. |
||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
void BitcoinApplication::createWindow(const NetworkStyle *networkStyle) | ||
|
@@ -327,7 +344,7 @@ void BitcoinApplication::parameterSetup() | |
|
||
void BitcoinApplication::InitPruneSetting(int64_t prune_MiB) | ||
{ | ||
optionsModel->SetPruneTargetGB(PruneMiBtoGB(prune_MiB), true); | ||
optionsModel->SetPruneTargetGB(PruneMiBtoGB(prune_MiB)); | ||
} | ||
|
||
void BitcoinApplication::requestInitialize() | ||
|
@@ -641,7 +658,9 @@ int GuiMain(int argc, char* argv[]) | |
app.createNode(*init); | ||
|
||
// Load GUI settings from QSettings | ||
app.createOptionsModel(gArgs.GetBoolArg("-resetguisettings", false)); | ||
if (!app.createOptionsModel(gArgs.GetBoolArg("-resetguisettings", false))) { | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (did_show_intro) { | ||
// Store intro dialog settings other than datadir (network specific) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are expected scenarios which run this code?
Asking because
settings.json
file I/O errors are handled in theInitSettings()
function.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: #602 (comment)
This is triggered if invalid data was written to the setting.json file (from a bug or from the user editing the file).
SettingTo{Bool,Int,String}
functions can throw exceptions,OptionsModel::Init
function will catch them and turn them into an error string, and this code log the error and show an error dialog.OptionsModel::Init
right now basically just returns false if an array or object value was found where a normal value was expected, but it could return other errors in other cases as code changes.