qml: Stabilize onboarding settings and data directories

bitcoin-core/gui-qml: PR #883

5 minor findings

Earlier concerns neither republished nor resolved: 1 minor finding · 2 suggestions. See the Run archive for their assessments.

Findings

Link

[minor] · Pre-creating the settings parent skips first-use wallets/ initialization

Completing onboarding with default settings can omit wallets/ for fresh default-directory or test-chain profiles, so subsequent wallets use the network root.

Location: qml/onboarding_settings.cpp:924 (head).

Details and suggested fix

prepare_node calls PrepareSettingsDirectory before common::InitConfig. With the default -settings, creating the settings parent creates the network data directory itself. Pinned Core creates wallets/ only when the base or network directory does not already exist, and the later EnsureSettingsDirectory has the same condition. Both therefore skip initialization. A new custom mainnet directory escapes this through EnsureDataDir, but a fresh default directory or missing test-chain network directory does not. Wallets still load, but new wallets use the network root, and restarting does not repair the layout. Create each missing base/network directory together with its wallets/ subdirectory before creating the settings parent, while leaving existing root-wallet profiles unchanged.

The onboardingApplyCreatesNewCustomDataDir assertion misses this because PrepareAndFinalizeModelApply goes directly to InitConfig without calling PrepareSettingsDirectory. Make that helper follow production ordering and cover fresh default-directory and test-chain profiles.


Link

[minor] · Settings-recovery Reset can discard a legacy-only data-directory selection

Recovery Reset can delete a legacy-only saved data-directory selection, making the next launch use the default profile; this combination has not been reported in production.

Location: qml/onboarding_settings.cpp:1214 (head).

Details and suggested fix

When unreadable settings.json causes onboarding to be skipped, startup can use Bitcoin-Qt's legacy strDataDir without migrating it into QML settings. Choosing Reset captures a backup, which makes FinalizeStartupSettings perform a full GUI reset with pending == nullptr. It clears GUI preferences and calls ClearLegacyGuiSettings, deleting the legacy directory selection. The preservation logic keeps only a strDataDir already present in QML settings, and copying the effective selection occurs only in the pending-onboarding branch. This session continues in the selected directory, but the next launch falls back to the default directory until the user selects the old folder again. Chain and wallet data remain on disk, and the active-QML GUI backup does not contain the legacy-only choice. Limit recovery Reset to settings.json, retaining the byte-exact backup, rather than treating it as -resetguisettings.


Link

[minor] · Chooser requests are ignored when settings.json is unreadable

With malformed settings.json in an accessible saved or default profile, -choosedatadir and GUI reset flags lead to Reset/Abort instead of the requested chooser.

Location: qml/onboarding_settings.cpp:1013 (head).

Details and suggested fix

ResolveOnboardingStartupStatus captures force_data_dir_chooser from -choosedatadir, bootstrap fReset, or the legacy reset flag, but returns on an unreadable settings file before consulting it. ShouldShowPreInitOnboarding then suppresses onboarding because settings_file_unreadable is true. The user must reset that profile, abort, or relaunch with an explicit -datadir instead of selecting another directory as before. Effective -resetguisettings is unaffected because it tolerates the failed read. Honor force_data_dir_chooser in the unreadable-settings branch by returning an onboarding status without the suppression flag, and add a regression combining -choosedatadir with malformed settings.


Link

[minor] · The settings-recovery dialog ignores application quit requests

Application QEvent::Quit events are consumed while the recovery prompt remains open, so quitting waits for manual dismissal.

Location: qml/bitcoin.cpp:384 (head).

Details and suggested fix

Unreadable settings.json without effective -resetguisettings reaches ErrorSettingsRead, which runs QMessageBox::exec() without access to QmlQuitHandler. The installed handler consumes application Quit events and emits quitRequested, but nothing connects that signal to this dialog. Unlike ExecStartupDialog, the prompt therefore remains open; choosing Reset afterward still performs recovery and node preparation before the pending quit is handled. Pass the quit handler into this function, return Abort when quitting is already pending, and close the box with Abort on quitRequested. Add coverage for quitting with the prompt open: the malformed-settings functional test currently supplies -resetguisettings and bypasses it.


Link

[minor] · New-folder preview can falsely report profile drift with external settings

For a new folder, an existing external settings file containing resetguisettings can falsely trigger profile-drift rejection; no current caller writing this combination was identified.

Location: qml/onboarding_settings.cpp:1126 (head).

Details and suggested fix

The new-directory preview reads configuration but never reads an existing file at an absolute or escaping relative -settings path before recording effective_reset. After confirmation creates the directory, InitConfig reads that external file with precedence over config. If its reset value differs from the preview, such as true with no configured reset, ValidatePendingApply rejects the unchanged profile. Core has already created the directory and rewritten the settings file by then. The omitted preview read predates this PR, but the reset-equality rejection is new; restarting after directory creation allows the existing-directory branch to read the file. Resolve and read an existing external settings file before computing the new-folder preview's reset value, keeping preview read-only and preserving unreadable-file recovery.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.