Skip to content

Commit 93cc53a

Browse files
committed
gui: Unregister wallet notifications before unloading wallets
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.
1 parent ef8f296 commit 93cc53a

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
@@ -352,6 +352,17 @@ void BitcoinApplication::requestShutdown()
352352
window->setClientModel(nullptr);
353353
pollShutdownTimer->stop();
354354

355+
#ifdef ENABLE_WALLET
356+
// Delete wallet controller here manually, instead of relying on Qt object
357+
// tracking (https://doc.qt.io/qt-5/objecttrees.html). This makes sure
358+
// walletmodel m_handle_* notification handlers are deleted before wallets
359+
// are unloaded, which can simplify wallet implementations. It also avoids
360+
// these notifications having to be handled while GUI objects are being
361+
// destroyed, making GUI code less fragile as well.
362+
delete m_wallet_controller;
363+
m_wallet_controller = nullptr;
364+
#endif // ENABLE_WALLET
365+
355366
delete clientModel;
356367
clientModel = nullptr;
357368

0 commit comments

Comments
 (0)