mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-09 18:00:13 +02:00
gui: Defer removeAndDeleteWallet when no modal widget is active
This commit is contained in:
@ -9,9 +9,11 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
#include <QWindow>
|
||||||
|
|
||||||
WalletController::WalletController(interfaces::Node& node, const PlatformStyle* platform_style, OptionsModel* options_model, QObject* parent)
|
WalletController::WalletController(interfaces::Node& node, const PlatformStyle* platform_style, OptionsModel* options_model, QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
@ -97,7 +99,17 @@ WalletModel* WalletController::getOrCreateWallet(std::unique_ptr<interfaces::Wal
|
|||||||
m_wallets.push_back(wallet_model);
|
m_wallets.push_back(wallet_model);
|
||||||
|
|
||||||
connect(wallet_model, &WalletModel::unload, [this, wallet_model] {
|
connect(wallet_model, &WalletModel::unload, [this, wallet_model] {
|
||||||
|
// Defer removeAndDeleteWallet when no modal widget is active.
|
||||||
|
// TODO: remove this workaround by removing usage of QDiallog::exec.
|
||||||
|
if (QApplication::activeModalWidget()) {
|
||||||
|
connect(qApp, &QApplication::focusWindowChanged, wallet_model, [this, wallet_model]() {
|
||||||
|
if (!QApplication::activeModalWidget()) {
|
||||||
removeAndDeleteWallet(wallet_model);
|
removeAndDeleteWallet(wallet_model);
|
||||||
|
}
|
||||||
|
}, Qt::QueuedConnection);
|
||||||
|
} else {
|
||||||
|
removeAndDeleteWallet(wallet_model);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Re-emit coinsSent signal from wallet model.
|
// Re-emit coinsSent signal from wallet model.
|
||||||
|
Reference in New Issue
Block a user