Browse Source

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: 723aa1b875
0.15
Wladimir J. van der Laan 7 years ago committed by MarcoFalke
parent
commit
6a62c745a9
  1. 1
      doc/files.md
  2. 22
      src/qt/optionsmodel.cpp

1
doc/files.md

@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
* wallet.dat: personal wallet (BDB) with keys and transactions
* .cookie: session RPC authentication cookie (written at start when cookie authentication is used, deleted on shutdown): since 0.12.0
* onion_private_key: cached Tor hidden service private key for `-listenonion`: since 0.12.0
* guisettings.ini.bak: backup of former GUI settings after `-resetguisettings` is used
Only used in pre-0.8.0
---------------------

22
src/qt/optionsmodel.cpp

@ -151,10 +151,32 @@ void OptionsModel::Init(bool resetSettings) @@ -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();

Loading…
Cancel
Save