aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-09-23 09:40:02 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2017-09-23 09:40:28 +0200
commit10a20bf7700e3d59f8e2ce3d4eaebf472d1754ce (patch)
tree923df0d0321cf69e967d7832bd17c246b4e4228d /src
parentaeed345c9bade5d52a3fbf0a943203f6c82e6344 (diff)
parent723aa1b8752c1d6c6c0a76059c532ebe2f406fc1 (diff)
downloadbitcoin-10a20bf7700e3d59f8e2ce3d4eaebf472d1754ce.tar.xz
Merge #11338: qt: Backup former GUI settings on `-resetguisettings`
723aa1b qt: Backup former GUI settings on `-resetguisettings` (Wladimir J. van der Laan) Pull request description: 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. (as discussed in yesterday's IRC meeting) Tree-SHA512: c64f5052d992eb02057ba285435f143c42d0cc456144a4c565e1c87be833737f9df750d0aee10810f85047c820d9b4f9f22fd94a6f09f4b28a9cf41b63a56586
Diffstat (limited to 'src')
-rw-r--r--src/qt/optionsmodel.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index e9960a01b1..feb00a33b0 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();