Skip to content

Commit

Permalink
Merge #1589: [GUI][Bug] Don't clear address label during send address…
Browse files Browse the repository at this point in the history
… validation

80aba61 [GUI][Bug] Don't clear address label during send address validation (Fuzzbawls)

Pull request description:

  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.

ACKs for top commit:
  random-zebra:
    utACK 80aba61
  furszy:
    utACK 80aba6

Tree-SHA512: 53e70190de3d4c90d0cbfdd91bd4cce6e50d7a828d0171a3570d36e6e477d3dcffb502ba4a2a9dcf1b3bc276bcce81b3a6a2621a68ec04c3979633a91ef701a1
  • Loading branch information
random-zebra committed May 5, 2020
2 parents 7694d5f + 80aba61 commit 507f75f
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 507f75f

Please sign in to comment.