gui: Fix itemWalletAddress leak when not tree mode

This commit is contained in:
João Barbosa 2019-11-16 23:41:16 +00:00
parent afa577c323
commit e8123eae40
2 changed files with 2 additions and 4 deletions

View file

@ -606,8 +606,7 @@ void CoinControlDialog::updateView()
int nDisplayUnit = model->getOptionsModel()->getDisplayUnit(); int nDisplayUnit = model->getOptionsModel()->getDisplayUnit();
for (const auto& coins : model->wallet().listCoins()) { for (const auto& coins : model->wallet().listCoins()) {
CCoinControlWidgetItem *itemWalletAddress = new CCoinControlWidgetItem(); CCoinControlWidgetItem* itemWalletAddress{nullptr};
itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked);
QString sWalletAddress = QString::fromStdString(EncodeDestination(coins.first)); QString sWalletAddress = QString::fromStdString(EncodeDestination(coins.first));
QString sWalletLabel = model->getAddressTableModel()->labelForAddress(sWalletAddress); QString sWalletLabel = model->getAddressTableModel()->labelForAddress(sWalletAddress);
if (sWalletLabel.isEmpty()) if (sWalletLabel.isEmpty())
@ -616,7 +615,7 @@ void CoinControlDialog::updateView()
if (treeMode) if (treeMode)
{ {
// wallet address // wallet address
ui->treeWidget->addTopLevelItem(itemWalletAddress); itemWalletAddress = new CCoinControlWidgetItem(ui->treeWidget);
itemWalletAddress->setFlags(flgTristate); itemWalletAddress->setFlags(flgTristate);
itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked); itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked);

View file

@ -31,7 +31,6 @@ class CCoinControlWidgetItem : public QTreeWidgetItem
{ {
public: public:
explicit CCoinControlWidgetItem(QTreeWidget *parent, int type = Type) : QTreeWidgetItem(parent, type) {} explicit CCoinControlWidgetItem(QTreeWidget *parent, int type = Type) : QTreeWidgetItem(parent, type) {}
explicit CCoinControlWidgetItem(int type = Type) : QTreeWidgetItem(type) {}
explicit CCoinControlWidgetItem(QTreeWidgetItem *parent, int type = Type) : QTreeWidgetItem(parent, type) {} explicit CCoinControlWidgetItem(QTreeWidgetItem *parent, int type = Type) : QTreeWidgetItem(parent, type) {}
bool operator<(const QTreeWidgetItem &other) const; bool operator<(const QTreeWidgetItem &other) const;