Skip to content

Commit 439e58c

Browse files
committed
Merge bitcoin-core#360: Unregister wallet notifications before unloading wallets
93cc53a gui: Unregister wallet notifications before unloading wallets (Russell Yanofsky) Pull request description: This change was originally part of both bitcoin/bitcoin#10102 and bitcoin/bitcoin#19101 and is required for both because it avoids the IPC wallet implementation in bitcoin/bitcoin#10102 and the WalletContext implementation in bitcoin/bitcoin#19101 needing to deal with notification objects that have stale pointers to deleted wallets. ACKs for top commit: promag: Code review ACK 93cc53a. hebasto: ACK 93cc53a Tree-SHA512: 805f50a493291ad0f7c48725fbc5058d58ebbdb0770befd51d8aa241209a13f8a46f5982481336ab8338cdc83e9017668089a71deccf1587308e841cf8697825
2 parents 9948f11 + 93cc53a commit 439e58c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/qt/bitcoin.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,17 @@ void BitcoinApplication::requestShutdown()
343343
window->setClientModel(nullptr);
344344
pollShutdownTimer->stop();
345345

346+
#ifdef ENABLE_WALLET
347+
// Delete wallet controller here manually, instead of relying on Qt object
348+
// tracking (https://doc.qt.io/qt-5/objecttrees.html). This makes sure
349+
// walletmodel m_handle_* notification handlers are deleted before wallets
350+
// are unloaded, which can simplify wallet implementations. It also avoids
351+
// these notifications having to be handled while GUI objects are being
352+
// destroyed, making GUI code less fragile as well.
353+
delete m_wallet_controller;
354+
m_wallet_controller = nullptr;
355+
#endif // ENABLE_WALLET
356+
346357
delete clientModel;
347358
clientModel = nullptr;
348359

0 commit comments

Comments
 (0)