mirror of
https://github.com/bitcoin-core/gui-qml.git
synced 2026-12-02 08:12:38 +00:00
Stabilize pre-init datadir and settings resolution #812
No reviewers
Labels
No labels
Android
Bug
Build system
Design suggestion
Doc
Needs design review
Needs rebase
Stage
UX
Up for grabs
Upstream
Wallet
duplicate
enhancement
good first issue
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin-core/gui-qml!812
Loading…
Reference in a new issue
No description provided.
Delete branch "settings-stablize"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This is a follow-up to #742.
Pre-init onboarding was doing too much work against the live
gArgs. It read config and settings to build the preview, then normal startup calledInitConfig()on the sameArgsManager. Ifbitcoin.confredirected the datadir, the second config read could start from a different place and fail before the main window opened.-resetguisettingshad a similar ordering problem. We could reset the bootstrap profile before Core had resolved the datadir and network it was actually going to use.This switches the pre-init reads to a scratch
ArgsManagerbuilt from the original argv. The datadir selected in onboarding is kept separate from the one resolved through config, and settings changes are finalized afterInitConfig()and the chain-specificQSettingssetup.A few related pieces are handled in the same path:
-resetguisettings=0is treated as false.strDataDiris preserved when GUI settings are cleared.settings.jsonthrough the existing reset-or-abort flow.Cancelling onboarding remains non-mutating. No settings are cleared and no backups are created.
Fixes #773.
Fixes #774.
This is related to #600, but does not close it. The Settings-page actions and
bitcoin.confopening flow are still separate work.#775 also remains open. An existing saved datadir that cannot be traversed can still fail before the chooser is shown.
tested ACK
49c2f253Built on Qt 6.4.2, unit and functional suites green, plus a headed pass under xcb. Confirmed the reset targets the resolved datadir's settings.json (custom datadir kept, default untouched), config-redirected datadirs reach the main window, and -resetguisettings=0 is a no-op.
Two items the green suites do not catch (both headed-only) are inline: #775 (an unreadable saved datadir still aborts at startup, a hard crash rather than a soft failure; details on the issue) and an empty reset backup when settings.json is unparseable. A few smaller issues inline too.
Nit: this string lost the translator comment that the Widgets
ErrorSettingsReadcarries. Inbitcoin/src/qt/bitcoin.cppthe samesetInformativeTexthas a/*: ... */comment above it explaining the reset-or-abort choice for translators. Since this is the one translated string in the new code, restoring the comment keeps parity and satisfies the translator-comment convention.This is #775, flagged at the fix point. Worth noting it is a hard crash (uncaught
filesystem_error-> SIGABRT on a mode-000 saved datadir), not the soft failure the issue text implies. Since this diff already reworks this path, atry/catch(const std::exception&)around theReadResolvedProfilecall routed tostatus.error, mirroring theSelectParamsguard, would close it here. Not blocking if you prefer to keep it in the follow-up.Nit: these new startup-error strings reach the user via
InitErrorbut are untranslatedQStringLiterals. Wrap the user-visible ones intr()(with%1placeholders rather than concatenation).Suggestion: when
settings.jsonis unreadable and a reset is requested, this backup captures an already-emptied file.InitConfigruns first; on an unparseablesettings.json,ReadSettingsFileclearsrw_settingsand fails, the read-error handler returns false to proceed, andInitConfigimmediately writes an empty document. Only afterward doesBackupSettingsFilerun, sosettings.json.bakholds the emptied file, not the original bytes. Reproduced: seed a corruptsettings.json, launch with-resetguisettings, finish onboarding; the.bakcontains only the auto-generated header. Low severity since the data was unreadable and the user asked to reset, but the backup gives false reassurance in the one case it exists for.Test gaps around this path:
run_malformed_settings_reset_recoversdoes not assert.bakcontents, andresetLegacyCleanupRollsBackOnWriteFailure(the only rollback-failure test for the legacy-cleanup path) isQSKIP'd off POSIX, so it is unverified on Windows CI. Consider backing up beforeInitConfig, or documenting the limitation, plus asserting the backup content.Suggestion: this rollback opens a fresh
QSettingson the same file while the originalactive_gui_settingsowner is still alive, so twoQSettingsback the same file with independent caches. The explicit restoresync()should win, butRestoreStoresinlegacy_settings_migration.cpphandles the same shape by resetting the owner first. The two rollback paths are inconsistent; resetting or rewriting through the existing object would be less fragile.Two settings concerns:
This opens and checks the active GUI settings file even when there is no onboarding change and no reset. I reproduced an unreadable file causing startup to stop before the main window, even though nothing needs to be changed. Can this store be opened only when it is actually needed? A test with an unreadable active store and no pending apply or reset would catch this.
I think this should be fixed here. The reset succeeds, but
settings.json.bakshould contain the original malformed file, not the empty file written byInitConfig(). Since this PR adds the backup sequence, can it stage the original bytes beforeInitConfig()changes the file, keep them as.bakonly after the reset succeeds, and test the backup contents?Superseded by 883