Skip to content

Commit a10972b

Browse files
committed
gui: Defer removeAndDeleteWallet when no modal widget is active
1 parent 717fd58 commit a10972b

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)