aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/qt/bitcoin.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index 09f453363d..f6ea147ddb 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -343,6 +343,17 @@ void BitcoinApplication::requestShutdown()
window->setClientModel(nullptr);
pollShutdownTimer->stop();
+#ifdef ENABLE_WALLET
+ // Delete wallet controller here manually, instead of relying on Qt object
+ // tracking (https://doc.qt.io/qt-5/objecttrees.html). This makes sure
+ // walletmodel m_handle_* notification handlers are deleted before wallets
+ // are unloaded, which can simplify wallet implementations. It also avoids
+ // these notifications having to be handled while GUI objects are being
+ // destroyed, making GUI code less fragile as well.
+ delete m_wallet_controller;
+ m_wallet_controller = nullptr;
+#endif // ENABLE_WALLET
+
delete clientModel;
clientModel = nullptr;