diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-09-15 11:50:45 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2017-10-04 11:53:18 +0200 |
commit | 6a62c745a9ce7d08667ab544ee3627e035e9d0ce (patch) | |
tree | d4829e2f6cf3d5c7e577be235d99c1b0fe79ef11 /src/qt | |
parent | 0fe2a9a196b2f81fed2ea84a5979e95f37094b22 (diff) |
qt: Backup former GUI settings on `-resetguisettings`
Writes the GUI settings to `guisettings.bak` in the data directory
before wiping them. This can be used to retroactively troubleshoot
issues (e.g. #11262) where `-resetguisettings` solves the problem.
Github-Pull: #11338
Rebased-From: 723aa1b8752c1d6c6c0a76059c532ebe2f406fc1
Diffstat (limited to 'src/qt')
-rw-r--r-- | src/qt/optionsmodel.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 77efef3e3c..a2dd52d9cb 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -151,10 +151,32 @@ void OptionsModel::Init(bool resetSettings) language = settings.value("language").toString(); } +/** Helper function to copy contents from one QSettings to another. + * By using allKeys this also covers nested settings in a hierarchy. + */ +static void CopySettings(QSettings& dst, const QSettings& src) +{ + for (const QString& key : src.allKeys()) { + dst.setValue(key, src.value(key)); + } +} + +/** Back up a QSettings to an ini-formatted file. */ +static void BackupSettings(const fs::path& filename, const QSettings& src) +{ + qWarning() << "Backing up GUI settings to" << GUIUtil::boostPathToQString(filename); + QSettings dst(GUIUtil::boostPathToQString(filename), QSettings::IniFormat); + dst.clear(); + CopySettings(dst, src); +} + void OptionsModel::Reset() { QSettings settings; + // Backup old settings to chain-specific datadir for troubleshooting + BackupSettings(GetDataDir(true) / "guisettings.ini.bak", settings); + // Save the strDataDir setting QString dataDir = Intro::getDefaultDataDirectory(); dataDir = settings.value("strDataDir", dataDir).toString(); |