Skip to content

Commit

Permalink
[GUI][Bug] Don't clear address label during send address validation
Browse files Browse the repository at this point in the history
The current sending flow clears and/or overwrites the user-supplied
address label multiple times, including when doing final address
validation after clicking the send button. This results in the entered
label never being used.

This stops the default clear and the overzealous replacing/setting of
the label text.
  • Loading branch information
Fuzzbawls committed May 4, 2020
1 parent 7fdf29f commit 80aba61
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/qt/pivx/send.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,8 @@ void SendWidget::onContactsClicked(SendMultiRow* entry)
menuContacts->setWalletModel(walletModel, AddressTableModel::Send);
connect(menuContacts, &ContactsDropdown::contactSelected, [this](QString address, QString label) {
if (focusedEntry) {
focusedEntry->setLabel(label);
if (label != "(no label)")
focusedEntry->setLabel(label);
focusedEntry->setAddress(address);
}
});
Expand Down
15 changes: 8 additions & 7 deletions src/qt/pivx/sendmultirow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ SendMultiRow::SendMultiRow(PWidget *parent) :
iconNumber->move(posIconX, posIconY);

connect(ui->lineEditAmount, &QLineEdit::textChanged, this, &SendMultiRow::amountChanged);
connect(ui->lineEditAddress, &QLineEdit::textChanged, this, &SendMultiRow::addressChanged);
connect(ui->lineEditAddress, &QLineEdit::textChanged, [this](){addressChanged(ui->lineEditAddress->text());});
connect(btnContact, &QAction::triggered, [this](){Q_EMIT onContactsClicked(this);});
connect(ui->btnMenu, &QPushButton::clicked, [this](){Q_EMIT onMenuClicked(this);});
}
Expand All @@ -83,9 +83,8 @@ CAmount SendMultiRow::getAmountValue(QString amount){
return isValid ? value : -1;
}

bool SendMultiRow::addressChanged(const QString& str)
bool SendMultiRow::addressChanged(const QString& str, bool fOnlyValidate)
{
ui->lineEditDescription->clear();
if(!str.isEmpty()) {
QString trimmedStr = str.trimmed();
const bool valid = walletModel->validateAddress(trimmedStr, this->onlyStakingAddressAccepted);
Expand All @@ -108,9 +107,11 @@ bool SendMultiRow::addressChanged(const QString& str)
}
} else {
setCssProperty(ui->lineEditAddress, "edit-primary-multi-book");
QString label = walletModel->getAddressTableModel()->labelForAddress(trimmedStr);
if (!label.isNull()){
ui->lineEditDescription->setText(label);
if (!fOnlyValidate) {
QString label = walletModel->getAddressTableModel()->labelForAddress(trimmedStr);
if (!label.isEmpty()) {
ui->lineEditDescription->setText(label);
}
}
}
updateStyle(ui->lineEditAddress);
Expand Down Expand Up @@ -162,7 +163,7 @@ bool SendMultiRow::validate()
retval = false;
setCssProperty(ui->lineEditAddress, "edit-primary-multi-book-error", true);
} else
retval = addressChanged(address);
retval = addressChanged(address, true);

CAmount value = getAmountValue(ui->lineEditAmount->text());

Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/sendmultirow.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public Q_SLOTS:

private Q_SLOTS:
void amountChanged(const QString&);
bool addressChanged(const QString&);
bool addressChanged(const QString&, bool fOnlyValidate = false);
void deleteClicked();
//void on_payTo_textChanged(const QString& address);
//void on_addressBookButton_clicked();
Expand Down

0 comments on commit 80aba61

Please sign in to comment.