Skip to content

Commit 1be0d18

Browse files
committed
Merge #477: Various fixes to Send, WalletController, and general QML
18e008c Signal currentRecipientChanged before deleting in SendRecipientsListModel::remove (johnny9) cc50078 Set m_selected_wallet to empty before unloading (johnny9) f8eb08f Reset current index before clearing in SendRecipientsListModel (johnny9) c8c54a1 Add missing buttonText id to EllipsisMenuToggleItem (johnny9) Pull request description: The following errors are resolved with these commits. Missing id for buttonText in EllipsesMenuToggleItem ``` 2025-07-27T01:40:01Z GUI: qrc:/qml/controls/EllipsisMenuToggleItem.qml:71: ReferenceError: buttonText is not defined 2025-07-27T01:40:01Z GUI: qrc:/qml/controls/EllipsisMenuToggleItem.qml:71:13: QML PropertyChanges: Cannot assign to non-existent property "color" ``` Null Property after toggling off Multiple Recipients toggle and removing Recipients with the "-" icon ``` 2025-07-27T01:40:03Z GUI: qrc:/qml/pages/wallet/Send.qml:258: TypeError: Cannot read property 'label' of null 2025-07-27T01:40:03Z GUI: qrc:/qml/pages/wallet/Send.qml:234: TypeError: Cannot read property 'amount' of null 2025-07-27T01:40:03Z GUI: qrc:/qml/pages/wallet/Send.qml:212: TypeError: Cannot read property 'amount' of null 2025-07-27T01:40:03Z GUI: qrc:/qml/pages/wallet/Send.qml:178: TypeError: Cannot read property 'address' of null ``` Null properties after all wallets are unloaded ``` 2025-07-27T01:40:44Z GUI: qrc:/qml/pages/wallet/Send.qml:258: TypeError: Cannot read property 'label' of null 2025-07-27T01:40:44Z GUI: qrc:/qml/pages/wallet/Send.qml:234: TypeError: Cannot read property 'amount' of null 2025-07-27T01:40:44Z GUI: qrc:/qml/pages/wallet/Send.qml:212: TypeError: Cannot read property 'amount' of null 2025-07-27T01:40:44Z GUI: qrc:/qml/pages/wallet/Send.qml:178: TypeError: Cannot read property 'address' of null 2025-07-27T01:40:44Z GUI: qrc:/qml/pages/wallet/Send.qml:31: TypeError: Cannot read property 'recipients' of null ``` ACKs for top commit: hebasto: ACK 18e008c, tested on Ubuntu 24.04. Tree-SHA512: 3c58676bb19cf524b3661e5f51260ace5cc70bc43ff94fbf14ae48ea7d2a69c76cdbe2988f02435ac53ea9dce0c68d1b8d8fc0163ceab376e3c5fa6fee82c001
2 parents 344ecc7 + 18e008c commit 1be0d18

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

qml/controls/EllipsisMenuToggleItem.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Button {
3939
anchors.centerIn: parent
4040
anchors.margins: 10
4141
CoreText {
42+
id: buttonText
4243
Layout.fillWidth: true
4344
Layout.alignment: Qt.AlignVCenter
4445
horizontalAlignment: Text.AlignLeft

qml/models/sendrecipientslistmodel.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,17 @@ void SendRecipientsListModel::remove()
9393
return;
9494
}
9595
beginRemoveRows(QModelIndex(), m_current, m_current);
96-
delete m_recipients.takeAt(m_current);
97-
endRemoveRows();
98-
Q_EMIT countChanged();
99-
10096
if (m_current > 0) {
97+
int index_to_remove = m_current;
10198
setCurrentIndex(m_current - 1);
99+
delete m_recipients.takeAt(index_to_remove);
102100
} else {
101+
auto removed_recipient = m_recipients.takeAt(m_current);
103102
Q_EMIT currentRecipientChanged();
103+
delete removed_recipient;
104104
}
105+
endRemoveRows();
106+
Q_EMIT countChanged();
105107
}
106108

107109
SendRecipient* SendRecipientsListModel::currentRecipient() const
@@ -152,6 +154,12 @@ void SendRecipientsListModel::clear()
152154

153155
void SendRecipientsListModel::clearToFront()
154156
{
157+
if (m_current != 0) {
158+
m_current = 0;
159+
Q_EMIT currentRecipientChanged();
160+
Q_EMIT currentIndexChanged();
161+
}
162+
155163
bool count_changed = false;
156164
while (m_recipients.size() > 1) {
157165
delete m_recipients.at(1);
@@ -167,10 +175,4 @@ void SendRecipientsListModel::clearToFront()
167175
m_totalAmount = m_recipients[0]->amount()->satoshi();
168176
Q_EMIT totalAmountChanged();
169177
}
170-
171-
if (m_current != 0) {
172-
m_current = 0;
173-
Q_EMIT currentRecipientChanged();
174-
Q_EMIT currentIndexChanged();
175-
}
176178
}

qml/walletqmlcontroller.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
WalletQmlController::WalletQmlController(interfaces::Node& node, QObject *parent)
1717
: QObject(parent)
1818
, m_node(node)
19-
, m_selected_wallet(new WalletQmlModel(parent))
19+
, m_empty_wallet(new WalletQmlModel(this))
20+
, m_selected_wallet(m_empty_wallet)
2021
, m_worker(new QObject)
2122
, m_worker_thread(new QThread(this))
2223
{
@@ -35,6 +36,7 @@ WalletQmlController::~WalletQmlController()
3536
m_worker_thread->quit();
3637
m_worker_thread->wait();
3738
delete m_worker;
39+
delete m_empty_wallet;
3840
}
3941

4042
void WalletQmlController::setSelectedWallet(QString path)
@@ -63,6 +65,8 @@ WalletQmlModel* WalletQmlController::selectedWallet() const
6365
void WalletQmlController::unloadWallets()
6466
{
6567
m_handler_load_wallet->disconnect();
68+
m_selected_wallet = m_empty_wallet;
69+
Q_EMIT selectedWalletChanged();
6670
QMutexLocker locker(&m_wallets_mutex);
6771
for (WalletQmlModel* wallet : m_wallets) {
6872
delete wallet;

qml/walletqmlcontroller.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public Q_SLOTS:
5454

5555
bool m_initialized{false};
5656
interfaces::Node& m_node;
57+
WalletQmlModel* m_empty_wallet;
5758
WalletQmlModel* m_selected_wallet;
5859
QObject* m_worker;
5960
QThread* m_worker_thread;

0 commit comments

Comments
 (0)