qml: Back up the wallet the backup dialog was opened for #1009

Closed
AndreaDiazCorreia wants to merge 1 commit from fix/backup-dialog-wallet-target into qt6 AGit
AndreaDiazCorreia commented 2026-10-13 21:59:02 +00:00 (Migrated from github.com)

Fixes #991.

The backup dialog used selectedWallet when accepted, so if another wallet was loaded while the dialog was open, that wallet was backed up instead.

The wallet is now pinned when the dialog opens. If it is closed before the dialog is accepted, the backup is refused with an error.

A QML test covers a selection change while the dialog is open.

Fixes #991. The backup dialog used `selectedWallet` when accepted, so if another wallet was loaded while the dialog was open, that wallet was backed up instead. The wallet is now pinned when the dialog opens. If it is closed before the dialog is accepted, the backup is refused with an error. A QML test covers a selection change while the dialog is open.
johnny9 (Migrated from github.com) reviewed 2026-10-14 00:27:32 +00:00
johnny9 (Migrated from github.com) left a comment

One UI clarity suggestion for the backup dialog.

One UI clarity suggestion for the backup dialog.
johnny9 (Migrated from github.com) commented 2026-10-14 00:27:32 +00:00

After opening the backup dialog for wallet A and loading wallet B, the page behind it shows B while this dialog still targets A. The dialog title is blank, so the editable filename is the only cue that it belongs to A. We should set title: qsTr("Back up wallet “%1”").arg(root.backupWalletName) here and extend the selection-change test to check that the title still names A after switching to B.

After opening the backup dialog for wallet A and loading wallet B, the page behind it shows B while this dialog still targets A. The dialog title is blank, so the editable filename is the only cue that it belongs to A. We should set `title: qsTr("Back up wallet “%1”").arg(root.backupWalletName)` here and extend the selection-change test to check that the title still names A after switching to B.
jarolrod (Migrated from github.com) reviewed 2026-10-14 06:35:33 +00:00
jarolrod (Migrated from github.com) commented 2026-10-14 06:35:33 +00:00

Tried a filename-label change locally on b03cf0554841, macOS 26.6.2 / Qt 6.9. It keeps A visible after loading B and editing the filename. Restoring the backups confirmed they still belonged to A.

A 64-character name was readable, but 160 characters stretched the expanded dialog to over three times its normal width. So I’d keep the title change, but wouldn’t use the full wallet name as the filename label as-is. We need a way to show it without letting the dialog grow indefinitely.

Tried a filename-label change locally on `b03cf0554841`, macOS 26.6.2 / Qt 6.9. It keeps A visible after loading B and editing the filename. Restoring the backups confirmed they still belonged to A. A 64-character name was readable, but 160 characters stretched the expanded dialog to over three times its normal width. So I’d keep the title change, but wouldn’t use the full wallet name as the filename label as-is. We need a way to show it without letting the dialog grow indefinitely.
jarolrod (Migrated from github.com) reviewed 2026-10-14 07:18:06 +00:00
jarolrod (Migrated from github.com) commented 2026-10-14 07:18:06 +00:00

Tried a QML confirmation after the native picker locally on b03cf0554841, macOS / Qt 6.9. Names up to 240 characters wrap without widening it, and a longer nested name scrolls.

Switching wallets in either dialog kept the original wallet, confirmed by restoring the backups. Unloading it disabled the backup, including after reloading the same name.

I think this is workable if we’re okay with the extra click. It lets us show the full wallet name and destination before writing, without having to customize the native panel.

240-character name after switching to wallet B:

long-name-after-switch

After unloading the original wallet:

wallet-unloaded
Tried a QML confirmation after the native picker locally on `b03cf0554841`, macOS / Qt 6.9. Names up to 240 characters wrap without widening it, and a longer nested name scrolls. Switching wallets in either dialog kept the original wallet, confirmed by restoring the backups. Unloading it disabled the backup, including after reloading the same name. I think this is workable if we’re okay with the extra click. It lets us show the full wallet name and destination before writing, without having to customize the native panel. 240-character name after switching to wallet B: <img width="1600" height="1394" alt="long-name-after-switch" src="https://git.fish.foo/attachments/d57b720e-7562-44a9-a8bf-2863fb6bbd77" /> After unloading the original wallet: <img width="1600" height="1394" alt="wallet-unloaded" src="https://git.fish.foo/attachments/0b749b85-d841-4aa9-9dc2-ca42d4d77f60" />
AndreaDiazCorreia (Migrated from github.com) reviewed 2026-10-16 00:06:57 +00:00
AndreaDiazCorreia (Migrated from github.com) commented 2026-10-16 00:06:57 +00:00

Thanks @johnny9 and @jarolrod. Went with the confirmation step jarolrod prototyped, plus the dialog title.

The save panel is now titled Back up wallet “”. After it is accepted, a QML confirmation shows the pinned wallet and the resolved destination. Both wrap, and the dialog width is fixed, so long names don't widen it. If the pinned wallet is unloaded while the confirmation is open, Back up is disabled and an inline error is shown.

To support this, AlertPopup gained a details slot and AlertAction an enabled property. Both are additive, and existing popups are unchanged.

Tested on Linux (Hyprland, Qt 6.11, GTK native dialog) with a 242-character wallet name:

  • Opened the backup for A, then unloaded and reloaded B over RPC so it became selected. The confirmation still named A. Restoring the written file produced A's descriptors, not B's.
  • Unloading the pinned wallet with the confirmation open disabled Back up.
  • Cancelling left the existing file untouched.

I have not tested on macOS.

New QML tests cover the selection change, cancel, unloading the pinned wallet, and a long name wrapping without widening the dialog.

One thing to note: when the chosen file already exists, the native panel asks to replace it before our confirmation appears, so that case takes two confirmations. On GTK, that native replace prompt also stretches with a long file name, which we can't control from here.

Thanks @johnny9 and @jarolrod. Went with the confirmation step jarolrod prototyped, plus the dialog title. The save panel is now titled Back up wallet “<name>”. After it is accepted, a QML confirmation shows the pinned wallet and the resolved destination. Both wrap, and the dialog width is fixed, so long names don't widen it. If the pinned wallet is unloaded while the confirmation is open, Back up is disabled and an inline error is shown. To support this, AlertPopup gained a details slot and AlertAction an enabled property. Both are additive, and existing popups are unchanged. Tested on Linux (Hyprland, Qt 6.11, GTK native dialog) with a 242-character wallet name: - Opened the backup for A, then unloaded and reloaded B over RPC so it became selected. The confirmation still named A. Restoring the written file produced A's descriptors, not B's. - Unloading the pinned wallet with the confirmation open disabled Back up. - Cancelling left the existing file untouched. I have not tested on macOS. New QML tests cover the selection change, cancel, unloading the pinned wallet, and a long name wrapping without widening the dialog. One thing to note: when the chosen file already exists, the native panel asks to replace it before our confirmation appears, so that case takes two confirmations. On GTK, that native replace prompt also stretches with a long file name, which we can't control from here.
pseudoramdom commented 2026-10-16 00:53:30 +00:00 (Migrated from github.com)

Hi, I'm working on a PR that fixes a class of related bugs (#992, #999, #1012, #1013, #1026, #1027, #1028, #1030 and #1037 ) where the wallet context changes while a menu or dialog is open.

IMO a safe, shared fix would be to dismiss those menus/dialogs and invalidate their pending actions whenever the wallet context changes. Switching back to the original wallet shouldn’t revive an old action.

What do you think about using that approach here too? We should just dismiss the dialog if the wallet context changes.

Hi, I'm working on a PR that fixes a class of related bugs (#992, #999, #1012, #1013, #1026, #1027, #1028, #1030 and #1037 ) where the wallet context changes while a menu or dialog is open. IMO a safe, shared fix would be to dismiss those menus/dialogs and invalidate their pending actions whenever the wallet context changes. Switching back to the original wallet shouldn’t revive an old action. What do you think about using that approach here too? We should just dismiss the dialog if the wallet context changes.
pseudoramdom commented 2026-10-16 06:44:05 +00:00 (Migrated from github.com)

Hi, I'm working on a PR that fixes a class of related bugs (#992, #999, #1012, #1013, #1026, #1027, #1028, #1030 and #1037 ) where the wallet context changes while a menu or dialog is open.

IMO a safe, shared fix would be to dismiss those menus/dialogs and invalidate their pending actions whenever the wallet context changes. Switching back to the original wallet shouldn’t revive an old action.

What do you think about using that approach here too? We should just dismiss the dialog if the wallet context changes.

https://github.com/bitcoin-core/gui-qml/pull/1046 is a broader fix that fixes #991 as well.

> Hi, I'm working on a PR that fixes a class of related bugs (#992, #999, #1012, #1013, #1026, #1027, #1028, #1030 and #1037 ) where the wallet context changes while a menu or dialog is open. > > IMO a safe, shared fix would be to dismiss those menus/dialogs and invalidate their pending actions whenever the wallet context changes. Switching back to the original wallet shouldn’t revive an old action. > > What do you think about using that approach here too? We should just dismiss the dialog if the wallet context changes. https://github.com/bitcoin-core/gui-qml/pull/1046 is a broader fix that fixes #991 as well.
AndreaDiazCorreia commented 2026-11-03 15:20:27 +00:00 (Migrated from github.com)

Closing this PR since #1049 already addresses the issue.

Closing this PR since #1049 already addresses the issue.
Sign in to join this conversation.
No description provided.