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)
qt: Backup former GUI settings on `-resetguisettings` #11338
pull laanwj wants to merge 1 commits into bitcoin:master from laanwj:2017_10_backup_resetguisettings changing 2 files +23 −0-
laanwj commented at 9:57 AM on September 15, 2017: member
- laanwj added the label GUI on Sep 15, 2017
- laanwj added the label Needs backport on Sep 15, 2017
- laanwj added this to the milestone 0.15.1 on Sep 15, 2017
-
in src/qt/optionsmodel.cpp:177 in 232a1089dd outdated
172 | void OptionsModel::Reset() 173 | { 174 | QSettings settings; 175 | 176 | + // Backup old settings for troubleshooting 177 | + backupSettings(GetDataDir(true) / "guisettings.bak", settings);
meshcollider commented at 10:00 AM on September 15, 2017:nit,
GetDataDir()argument defaults totrueso it'd be clearer to leave it out imo
laanwj commented at 10:04 AM on September 15, 2017:Isn't it the other way around: clearer to leave it in, because it's explicit?
meshcollider commented at 10:08 AM on September 15, 2017:Normally I'd say yes, but in this case it just leaves me wondering what the argument is doing, because in most other cases of
GetDataDirin the code, the argument is left out. Personal preference
laanwj commented at 10:11 AM on September 15, 2017:During the initialization sequence it's really important to get this right. E.g. I had to check the order in
src/qt/bitcoin.cppthat callingGetDataDir(true)was allowed at this point.Agree that boolean arguments are unclear, so are default arguments, so it's kind of choosing between evils here. Instead of an argument to
GetDataDirwe should have doneGetSpecificDataDirandGetRootDataDiror such. Anyhow... I don't think this code is particularly unclear, I'll add 'to chain-specific datadir' in the comment.in src/qt/optionsmodel.cpp:159 in 232a1089dd outdated
150 | @@ -151,10 +151,31 @@ void OptionsModel::Init(bool resetSettings) 151 | language = settings.value("language").toString(); 152 | } 153 | 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()) {
meshcollider commented at 10:01 AM on September 15, 2017:nit, space between
&keyand the colon
laanwj commented at 10:04 AM on September 15, 2017:Will fix
meshcollider commented at 10:02 AM on September 15, 2017: contributorutACK https://github.com/bitcoin/bitcoin/pull/11338/commits/232a1089dd90878ca95a01f0ce053c4b1ffba88e, really good idea :+1:
Couple of small nits
laanwj force-pushed on Sep 15, 2017laanwj force-pushed on Sep 15, 2017meshcollider commented at 10:14 AM on September 15, 2017: contributorlaanwj force-pushed on Sep 15, 2017laanwj commented at 10:56 AM on September 15, 2017: memberTravis was failing. Changed
qInfotoqWarning, asqInfowas only introduced in Qt 5.5 and the result is the same anyhow: it unconditionally ends up in debug.log.in src/qt/optionsmodel.cpp:157 in f725dbbfc2 outdated
150 | @@ -151,10 +151,32 @@ void OptionsModel::Init(bool resetSettings) 151 | language = settings.value("language").toString(); 152 | } 153 | 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)
promag commented at 1:31 PM on September 15, 2017:Don't see the benefit of this function, move the code to
backupSettings()? Otherwise&next to type name.
laanwj commented at 2:17 PM on September 15, 2017:The point is that this is a general function, it could be also e.g. used to restore QSettings from a backup, if that is ever necessary. Would prefer to keep it. Better too much factoring than too little.
promag commented at 2:23 PM on September 15, 2017:Ok then, just update to
CopySettingsand move&.in src/qt/optionsmodel.cpp:165 in f725dbbfc2 outdated
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)
promag commented at 1:32 PM on September 15, 2017:Rename to
BackupSettingsand&next to type name.in src/qt/optionsmodel.cpp:159 in f725dbbfc2 outdated
150 | @@ -151,10 +151,32 @@ void OptionsModel::Init(bool resetSettings) 151 | language = settings.value("language").toString(); 152 | } 153 | 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()) {
promag commented at 1:33 PM on September 15, 2017:&next to type name.in doc/files.md:18 in f725dbbfc2 outdated
14 | @@ -15,6 +15,7 @@ 15 | * wallet.dat: personal wallet (BDB) with keys and transactions 16 | * .cookie: session RPC authentication cookie (written at start when cookie authentication is used, deleted on shutdown): since 0.12.0 17 | * onion_private_key: cached Tor hidden service private key for `-listenonion`: since 0.12.0 18 | +* guisettings.bak: backup of former GUI settings after `-resetguisettings` is used
promag commented at 1:35 PM on September 15, 2017:.ini.bak?
laanwj commented at 2:19 PM on September 15, 2017:Yeah why not...
promag commented at 2:17 PM on September 16, 2017:Missing doc update.
promag commented at 1:37 PM on September 15, 2017: memberutACK modulus nits.
TheBlueMatt commented at 9:18 PM on September 15, 2017: memberTested ACK f725dbbfc2b096dabb53f9ee9b4f5ae3d659b412, needs squash obviously, didn't bother to try to review in-depth for whether this is going to put the guisettings.bak file in a strange datadir (bitcoin.conf-based? the old GUI settings one?) but there isnt a "correct" answer there anyway, so I cant say I care much.
sipa commented at 11:26 PM on September 15, 2017: memberConcept ACK
jonasschnelli commented at 11:30 PM on September 15, 2017: contributorutACK f725dbbfc2b096dabb53f9ee9b4f5ae3d659b412
Since this uses
QSettings::IniFormat, there is no easy way how to restore a such backup. Is the backup file only intended to use for inspection of old values or also for a full restore? The later would very likely require a restore function (QSettings::IniFormatto native format or similar).laanwj commented at 5:04 AM on September 16, 2017: memberdidn't bother to try to review in-depth for whether this is going to put the guisettings.bak file in a strange datadir (bitcoin.conf-based? the old GUI settings one?)
I think that's handled, it puts it in the new datadir that you have to select when using
-resetguisettings.Since this uses QSettings::IniFormat, there is no easy way how to restore a such backup. Is the backup file only intended to use for inspection of old values or also for a full restore?
Not opposed to restore functionality if there is a pressing use-case, although the intended purpose (as mentioned in OP) is diagnostics. This is much easier with .ini format. Also windows' NativeFormat cannot be exported to an arbitrary file just to other registry paths.
promag commented at 2:25 PM on September 16, 2017: memberTested ACK. It works even if the file already exists in either INI or other format (it's always overwritten).
There are still some code nits. One small and final thing, for me this is more of a dump than backup.
achow101 commented at 4:19 PM on September 16, 2017: memberthere is no easy way how to restore a such backup.
I don't think there needs to be a way to restore such a backup. This backup is only created when you run
-resetguisettingswhich implies that the settings are corrupted anyways and you don't want a backup of something that's corrupted.promag commented at 4:22 PM on September 16, 2017: memberwhich implies that the settings are corrupted
Or settings are fine and there is a bug?
achow101 commented at 4:43 PM on September 16, 2017: membertACK b28af386a38e6cb636683346b671b90d44382d74
jonasschnelli commented at 5:07 AM on September 18, 2017: contributorFound a strange issue while testing this. Compiling locally on OSX with MacOS 10.12.6 with Qt5.9.0 works perfect (
guisettings.ini.bakis present after running with-resetguisettings). However, using the gtitian build (https://bitcoin.jonasschnelli.ch/build/312) will result in not creating theguisettings.ini.bakfile. Not sure if it is a local issue but would be good if someone could test this (via gitian)MarcoFalke commented at 10:06 AM on September 18, 2017: member@jonasschnelli The embedded commit hash does not match the advertised commit hash on the website of the downloaded gitian binaries.
jonasschnelli commented at 3:57 AM on September 19, 2017: contributor@MarcoFalke: the commit hash is different because my build script builds it on top of master. I just did everything again and the gtitian version does not create the backup file. https://bitcoin.jonasschnelli.ch/build/315 (Maybe someone should double-check via an gitian build).
achow101 commented at 4:54 AM on September 19, 2017: member@jonasschnelli I performed my own gitian build and tested it but could not reproduce your issue. It will create
guisettings.ini.bakas it should.I did notice that if you did not have any gui settings to begin with, the file will not be created. Perhaps that's what you are seeing?
jonasschnelli commented at 2:08 PM on September 19, 2017: contributor@achow101: even with enabling coincontrol I had no success on OSX. What OS did you test? It may be a platform issue?
achow101 commented at 2:19 PM on September 19, 2017: member@jonasschnelli I am using Ubuntu 17.04
laanwj commented at 2:29 PM on September 19, 2017: memberI did notice that if you did not have any gui settings to begin with, the file will not be created. Perhaps that's what you are seeing?
Hm, that's interesting, haven't thought about that. I think that behavior makes sense, though.
gmaxwell approvedgmaxwell commented at 4:47 AM on September 23, 2017: contributorut(not very useful at reviewing QT stuff)ACK.
723aa1b875qt: 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.
laanwj force-pushed on Sep 23, 2017laanwj commented at 7:39 AM on September 23, 2017: memberSquashed 4e9dc85e0f0ef09a8c123681fa1758f1b173c9d7 f725dbbfc2b096dabb53f9ee9b4f5ae3d659b412 0f29983c80f91fccddfff7e045ed224ce93bce81 b28af386a38e6cb636683346b671b90d44382d74 → 723aa1b8752c1d6c6c0a76059c532ebe2f406fc1
laanwj merged this on Sep 23, 2017laanwj closed this on Sep 23, 2017laanwj referenced this in commit 10a20bf770 on Sep 23, 2017MarcoFalke referenced this in commit 6a62c745a9 on Oct 4, 2017MarcoFalke removed the label Needs backport on Oct 4, 2017jasonbcox referenced this in commit cbabd40c5b on Sep 13, 2019codablock referenced this in commit 6ab6809598 on Sep 25, 2019jonspock referenced this in commit 084b67338d on Dec 22, 2019proteanx referenced this in commit 30818584ed on Dec 23, 2019barrystyle referenced this in commit acb1fa50d3 on Jan 22, 2020MarcoFalke locked this on Sep 8, 2021LabelsMilestone
0.15.2
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me