Skip to content

Commit abd914e

Browse files
committed
Merge #15614: gui: Defer removeAndDeleteWallet when no modal widget is active
a10972b gui: Defer removeAndDeleteWallet when no modal widget is active (João Barbosa) Pull request description: Fixes #15310. Tree-SHA512: ac91a4e37020d3a854830c50c0a7a45c2c0537f80be492ec5e9ba7daf90725e912f9dcc324605493599c36180e1d3bcdfa86840b7325cba208b7e93fbe7be368
2 parents 717fd58 + a10972b commit abd914e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/qt/walletcontroller.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99

1010
#include <algorithm>
1111

12+
#include <QApplication>
1213
#include <QMessageBox>
1314
#include <QMutexLocker>
1415
#include <QThread>
16+
#include <QWindow>
1517

1618
WalletController::WalletController(interfaces::Node& node, const PlatformStyle* platform_style, OptionsModel* options_model, QObject* parent)
1719
: QObject(parent)
@@ -97,7 +99,17 @@ WalletModel* WalletController::getOrCreateWallet(std::unique_ptr<interfaces::Wal
9799
m_wallets.push_back(wallet_model);
98100

99101
connect(wallet_model, &WalletModel::unload, [this, wallet_model] {
100-
removeAndDeleteWallet(wallet_model);
102+
// Defer removeAndDeleteWallet when no modal widget is active.
103+
// TODO: remove this workaround by removing usage of QDiallog::exec.
104+
if (QApplication::activeModalWidget()) {
105+
connect(qApp, &QApplication::focusWindowChanged, wallet_model, [this, wallet_model]() {
106+
if (!QApplication::activeModalWidget()) {
107+
removeAndDeleteWallet(wallet_model);
108+
}
109+
}, Qt::QueuedConnection);
110+
} else {
111+
removeAndDeleteWallet(wallet_model);
112+
}
101113
});
102114

103115
// Re-emit coinsSent signal from wallet model.

0 commit comments

Comments
 (0)