From 95de84bb290adf889de1b2dfc2c96b5a92d4fede Mon Sep 17 00:00:00 2001 From: Pablo Martin Date: Thu, 18 Jun 2026 14:36:22 -0300 Subject: [PATCH 1/2] qt: Close transaction detail dialogs on wallet switch Add WalletView::closeTransactionDialogs() which delegates to TransactionView::closeOpenedDialogs(). Call it from WalletFrame::setCurrentWallet() when hiding the outgoing wallet view, so any open TransactionDescDialog windows from the previous wallet are closed before the view is hidden. --- src/qt/walletframe.cpp | 1 + src/qt/walletview.cpp | 5 +++++ src/qt/walletview.h | 3 +++ 3 files changed, 9 insertions(+) diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp index ec5b51235ed..8642aba7ccc 100644 --- a/src/qt/walletframe.cpp +++ b/src/qt/walletframe.cpp @@ -98,6 +98,7 @@ void WalletFrame::setCurrentWallet(WalletModel* wallet_model) QSizePolicy sp = view_about_to_hide->sizePolicy(); sp.setHorizontalPolicy(QSizePolicy::Ignored); view_about_to_hide->setSizePolicy(sp); + view_about_to_hide->closeTransactionDialogs(); } WalletView *walletView = mapWalletViews.value(wallet_model); diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index 9f6084c6169..89e676397ea 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -284,3 +284,8 @@ void WalletView::disableTransactionView(bool disable) { transactionView->setDisabled(disable); } + +void WalletView::closeTransactionDialogs() +{ + transactionView->closeOpenedDialogs(); +} diff --git a/src/qt/walletview.h b/src/qt/walletview.h index 53e94194ea3..71d655fc3c5 100644 --- a/src/qt/walletview.h +++ b/src/qt/walletview.h @@ -107,6 +107,9 @@ public Q_SLOTS: /** Show progress dialog e.g. for rescan */ void showProgress(const QString &title, int nProgress); + /** Close all open transaction detail dialogs for this wallet view. */ + void closeTransactionDialogs(); + private Q_SLOTS: void disableTransactionView(bool disable); From b30b75d64e93c58e0bdd790d54570a10f1ebfd9c Mon Sep 17 00:00:00 2001 From: Pablo Martin Date: Thu, 18 Jun 2026 14:36:22 -0300 Subject: [PATCH 2/2] qt, test: Add test for closing transaction detail dialogs on wallet switch Add TestCloseTransactionDialogs() which selects a transaction, opens its detail dialog via showDetails(), then calls closeOpenedDialogs() and verifies the dialog is gone. Exercises the path triggered by WalletView::closeTransactionDialogs() during a wallet switch. --- src/qt/test/wallettests.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp index a2983c23979..996bdb012af 100644 --- a/src/qt/test/wallettests.cpp +++ b/src/qt/test/wallettests.cpp @@ -245,6 +245,37 @@ struct MiniGUI { }; +void TestCloseTransactionDialogs(TransactionView& transactionView, const Txid& txid) +{ + // Select a transaction row in the view. + QTableView* table = transactionView.findChild("transactionView"); + QModelIndex index = FindTx(*table->selectionModel()->model(), txid); + QVERIFY2(index.isValid(), "Could not find txid for dialog test"); + table->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); + + // Open the transaction details dialog. + bool invoked = QMetaObject::invokeMethod(&transactionView, "showDetails"); + QVERIFY(invoked); + + // Verify a TransactionDescDialog is now open. + int open_count = 0; + for (QWidget* widget : QApplication::topLevelWidgets()) { + if (widget->inherits("TransactionDescDialog")) ++open_count; + } + QCOMPARE(open_count, 1); + + // Simulate wallet switch: close open dialogs. + transactionView.closeOpenedDialogs(); + qApp->processEvents(); + + // Verify the dialog is gone. + int closed_count = 0; + for (QWidget* widget : QApplication::topLevelWidgets()) { + if (widget->inherits("TransactionDescDialog")) ++closed_count; + } + QCOMPARE(closed_count, 0); +} + //! Simple qt wallet tests. // // Test widgets can be debugged interactively calling show() on them and @@ -293,6 +324,9 @@ void TestGUI(interfaces::Node& node, const std::shared_ptr& wallet) BumpFee(transactionView, txid2, /*expectDisabled=*/false, /*expectError=*/{}, /*cancel=*/false); BumpFee(transactionView, txid2, /*expectDisabled=*/true, /*expectError=*/"already bumped", /*cancel=*/false); + // Verify transaction detail dialogs are closed when the wallet view is hidden (e.g. on wallet switch). + TestCloseTransactionDialogs(transactionView, txid1); + // Check current balance on OverviewPage OverviewPage overviewPage(platformStyle.get()); overviewPage.setWalletModel(&walletModel);