Merge #15614: gui: Defer removeAndDeleteWallet when no modal widget is active

a10972bc0 gui: Defer removeAndDeleteWallet when no modal widget is active (João Barbosa)

Pull request description:

  Fixes #15310.

Tree-SHA512: ac91a4e37020d3a854830c50c0a7a45c2c0537f80be492ec5e9ba7daf90725e912f9dcc324605493599c36180e1d3bcdfa86840b7325cba208b7e93fbe7be368
This commit is contained in:
Jonas Schnelli 2019-03-22 11:07:35 +01:00
commit abd914ed34
No known key found for this signature in database
GPG key ID: 1EB776BB03C7922D

View file

@ -9,9 +9,11 @@
#include <algorithm>
#include <QApplication>
#include <QMessageBox>
#include <QMutexLocker>
#include <QThread>
#include <QWindow>
WalletController::WalletController(interfaces::Node& node, const PlatformStyle* platform_style, OptionsModel* options_model, QObject* parent)
: QObject(parent)
@ -97,7 +99,17 @@ WalletModel* WalletController::getOrCreateWallet(std::unique_ptr<interfaces::Wal
m_wallets.push_back(wallet_model);
connect(wallet_model, &WalletModel::unload, [this, wallet_model] {
removeAndDeleteWallet(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);
}
}, Qt::QueuedConnection);
} else {
removeAndDeleteWallet(wallet_model);
}
});
// Re-emit coinsSent signal from wallet model.