Skip to content

Commit f42dbfc

Browse files
fix(qt): clear owned filter without wallet
1 parent 5c34657 commit f42dbfc

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/qt/masternodelist.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <QHeaderView>
2222
#include <QMetaObject>
2323
#include <QSettings>
24+
#include <QSignalBlocker>
2425
#include <QThread>
2526

2627
#include <set>
@@ -189,6 +190,13 @@ void MasternodeList::setWalletModel(WalletModel* model)
189190
if (walletModel) {
190191
QSettings settings;
191192
ui->checkBoxOwned->setChecked(settings.value("mnListOwnedOnly", false).toBool());
193+
} else {
194+
const QSignalBlocker blocker{ui->checkBoxOwned};
195+
ui->checkBoxOwned->setChecked(false);
196+
m_proxy_model->setShowOwnedOnly(false);
197+
m_proxy_model->setMyMasternodeHashes({});
198+
m_proxy_model->forceInvalidateFilter();
199+
updateFilteredCount();
192200
}
193201
}
194202

src/qt/test/masternodewidgettests.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#include <QAbstractButton>
3131
#include <QApplication>
32+
#include <QCheckBox>
3233
#include <QComboBox>
3334
#include <QDoubleSpinBox>
3435
#include <QLabel>
@@ -666,8 +667,10 @@ void MasternodeWidgetTests::masternodeListRegistrationAvailability()
666667

667668
MasternodeList list;
668669
auto* const register_button{list.findChild<QPushButton*>("btnRegisterMasternode")};
670+
auto* const owned_checkbox{list.findChild<QCheckBox*>("checkBoxOwned")};
669671
auto* const context_menu{list.findChild<QMenu*>(QString{}, Qt::FindDirectChildrenOnly)};
670672
QVERIFY(register_button != nullptr);
673+
QVERIFY(owned_checkbox != nullptr);
671674
QVERIFY(context_menu != nullptr);
672675
QVERIFY(context_menu->toolTipsVisible());
673676
QVERIFY(!register_button->isEnabled());
@@ -680,6 +683,20 @@ void MasternodeWidgetTests::masternodeListRegistrationAvailability()
680683
list.setClientModel(&client_model);
681684
QVERIFY(register_button->isEnabled());
682685

686+
owned_checkbox->setChecked(true);
687+
list.setWalletModel(nullptr);
688+
QVERIFY(!register_button->isEnabled());
689+
QVERIFY(register_button->toolTip().contains("requires a wallet", Qt::CaseInsensitive));
690+
QVERIFY(!owned_checkbox->isEnabled());
691+
QVERIFY(!owned_checkbox->isChecked());
692+
693+
// Attaching the wallet again restores the user's saved owned-only choice.
694+
list.setWalletModel(&wallet_model);
695+
QVERIFY(register_button->isEnabled());
696+
QVERIFY(owned_checkbox->isEnabled());
697+
QVERIFY(owned_checkbox->isChecked());
698+
owned_checkbox->setChecked(false);
699+
683700
list.setClientModel(nullptr);
684701
QVERIFY(!register_button->isEnabled());
685702
QVERIFY(register_button->toolTip().contains("node is ready", Qt::CaseInsensitive));

0 commit comments

Comments
 (0)