4 minor findings · 1 suggestion
Findings
[minor] · Import busy state clears before restoreWallet() returns
Handling Core's early load notification clears import progress before restore completion, allowing precisely timed actions to queue more work or lose or misattribute the success notification.
Location: qml/walletqmlcontroller.cpp:484 (head).
Details and suggested fix
handleLoadWallet() reaches addOrSelectWalletModel(), which calls finishWalletImport() and clears the marker used by the import guards. In the pinned Core, the load notification precedes AddWallet(), postInitProcess() and the settings update; lastImportedWalletName and walletImportSucceeded arrive later through executor completion. If the user opens a fresh creation modal during that interval, MainWindow suppresses the toast while the fresh flow ignores success because its local importingWallet is false. Starting another import instead lets that flow consume the first import's success. The unmeasured interval covers only post-load work and a settings write, so these consequences require precise timing; another import also requires choosing a file. Clear the marker only in the import command's completion and failure callbacks, retaining the name during notification handling to avoid changing selection. Add a test that delivers the load notification while keeping restoreWallet() blocked, then checks that create, import and closed-wallet loads remain refused. The current test releases its semaphore before delivering the notification.
[minor] · Import success tests can outlive their fake wallet state
The two new import success tests use a non-draining controller, allowing asynchronous unload cleanup to access destroyed FakeWallet::State locals.
Location: test/test_walletqmlcontroller.cpp:814 (head).
Details and suggested fix
importWalletLeavesLoadedWalletsSelectable() and importWalletWithoutSelectedWalletSelectsIt() finish with open wallet models but construct a plain WalletQmlController. Its destructor starts shutdown without waiting. Model shutdown queues the unload handler's cleanup on a backend executor, and that handler captures a raw State* and locks its mutex. The task can therefore run after the test destroys the state, causing nondeterministic use-after-free or destroyed-mutex failures. Use the existing DrainingWalletController fixture so cleanup finishes before the state locals go away. The first test also needs a scope guard that releases allow_restore_return on assertion failure; keep the semaphores alive until the draining controller has finished, as the guarded sibling test does.
[minor] · Migration can queue behind a background import
Unlike create and import, migration does not check walletWorkerBusy(), so confirmation during a background rescan can queue a delayed migration that later changes the selected wallet.
Location: qml/walletqmlcontroller.cpp:702 (head).
Details and suggested fix
migrateWallet() checks initialization but not import progress. A valid target reaches startWalletMigration() and submits to the same executor running restoreWallet(); successful completion then selects the migrated wallet through handleLoadWallet(). This matters if a migration or passphrase popup remains open while an import starts through the native Add Wallet menu: after dismissing the newly closable import modal, the user can confirm the underlying migration. A migration failure can also reopen its popup for retry while an import runs. The operation then waits behind a potentially minutes-long rescan before changing selection. The missing controller guard predates this PR, but dismissing the import modal newly exposes the retained-popup path; native-menu interaction under a QML modal has not been verified on a platform. Reject migration while walletWorkerBusy() is true, before clearing status or submitting, and report a recoverable migration error so the user can retry.
[minor] · A failed import can leave a nonexistent wallet in the selector
Refreshing the selector during an import makes its row directory-backed, so a later restore failure preserves it as a closed wallet even after Core removes the copied database.
Location: qml/models/walletlistmodel.cpp:179 (head).
Details and suggested fix
RestoreWallet() copies the backup before loading and rescanning it. Opening the selector during that work calls listWalletDir(), which can discover the copied SQLite database and rebuild its row with from_wallet_dir=true. If loading subsequently fails, Core removes the copied file, but setImportingWallet("") removes only synthetic rows. The existing row therefore becomes an enabled closed wallet; after dismissing the import error dialog, clicking it attempts to load a path that no longer exists and produces another error. If it is the only row, noWalletsFound also remains false. Reopening the selector refreshes and repairs the list. Reconcile directory membership on import failure, for example by calling listWalletDir(). Test failure immediately after a refresh that saw the copied wallet, without the extra post-removal refresh used by the current test.
Optional improvements
[suggestion] · Background import failures interrupt the active workflow
Unlike success, a background import failure automatically opens a focused modal without checking whether the user is already working in another dialog.
Location: qml/pages/MainWindow.qml:369 (head).
Details and suggested fix
onWalletImportFailed() only checks the creation modal itself before calling openForImportError(). Since that popup is modal, dimmed and focus-taking, a failure arriving during another wallet task can interrupt its dialog or text entry. This is a workflow tradeoff rather than lost state: the popup is dismissible, and automatic reopening keeps errors discoverable when the failed import row disappears. Prefer a persistent, non-auto-dismissing error banner with a “View details” action that opens the existing error page. That retains discoverability without immediately taking focus from the work this change lets users continue.