Skip to content

Commit

Permalink
gui: Defer removeAndDeleteWallet when no modal widget is active
Browse files Browse the repository at this point in the history
  • Loading branch information
promag authored and jonasschnelli committed Mar 22, 2019
1 parent 238ef33 commit 98a24a2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/qt/walletcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 98a24a2

Please sign in to comment.