From 685c122fefaab987d84bc47e5fb042e60cf43d6e Mon Sep 17 00:00:00 2001 From: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com> Date: Thu, 21 Apr 2022 17:01:29 -0500 Subject: [PATCH] fix(qt): fix crash when first enabling governance tab due to null-ptr deref (#4795) Decided to also apply the same logic to the other items so that we don't do nullptr dereferences replication ``` ./src/qt/dash-qt --regtest --resetguisettings Enable governance shutdown ``` --- src/qt/walletview.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index f096403930..721d3ae343 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -153,14 +153,20 @@ void WalletView::setClientModel(ClientModel *_clientModel) { this->clientModel = _clientModel; - overviewPage->setClientModel(_clientModel); - sendCoinsPage->setClientModel(_clientModel); - coinJoinCoinsPage->setClientModel(_clientModel); + if (overviewPage != nullptr) { + overviewPage->setClientModel(_clientModel); + } + if (sendCoinsPage != nullptr) { + sendCoinsPage->setClientModel(_clientModel); + } + if (coinJoinCoinsPage != nullptr) { + coinJoinCoinsPage->setClientModel(_clientModel); + } QSettings settings; - if (settings.value("fShowMasternodesTab").toBool()) { + if (settings.value("fShowMasternodesTab").toBool() && masternodeListPage != nullptr) { masternodeListPage->setClientModel(_clientModel); } - if (settings.value("fShowGovernanceTab").toBool()) { + if (settings.value("fShowGovernanceTab").toBool() && governanceListPage != nullptr) { governanceListPage->setClientModel(_clientModel); } }