Skip to content

Commit 10a20bf

Browse files
committed
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
2 parents aeed345 + 723aa1b commit 10a20bf

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

doc/files.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* wallet.dat: personal wallet (BDB) with keys and transactions
1616
* .cookie: session RPC authentication cookie (written at start when cookie authentication is used, deleted on shutdown): since 0.12.0
1717
* onion_private_key: cached Tor hidden service private key for `-listenonion`: since 0.12.0
18+
* guisettings.ini.bak: backup of former GUI settings after `-resetguisettings` is used
1819

1920
Only used in pre-0.8.0
2021
---------------------

src/qt/optionsmodel.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,32 @@ void OptionsModel::Init(bool resetSettings)
151151
language = settings.value("language").toString();
152152
}
153153

154+
/** Helper function to copy contents from one QSettings to another.
155+
* By using allKeys this also covers nested settings in a hierarchy.
156+
*/
157+
static void CopySettings(QSettings& dst, const QSettings& src)
158+
{
159+
for (const QString& key : src.allKeys()) {
160+
dst.setValue(key, src.value(key));
161+
}
162+
}
163+
164+
/** Back up a QSettings to an ini-formatted file. */
165+
static void BackupSettings(const fs::path& filename, const QSettings& src)
166+
{
167+
qWarning() << "Backing up GUI settings to" << GUIUtil::boostPathToQString(filename);
168+
QSettings dst(GUIUtil::boostPathToQString(filename), QSettings::IniFormat);
169+
dst.clear();
170+
CopySettings(dst, src);
171+
}
172+
154173
void OptionsModel::Reset()
155174
{
156175
QSettings settings;
157176

177+
// Backup old settings to chain-specific datadir for troubleshooting
178+
BackupSettings(GetDataDir(true) / "guisettings.ini.bak", settings);
179+
158180
// Save the strDataDir setting
159181
QString dataDir = Intro::getDefaultDataDirectory();
160182
dataDir = settings.value("strDataDir", dataDir).toString();

0 commit comments

Comments
 (0)