aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonas Schnelli <dev@jonasschnelli.ch>2020-05-13 10:13:02 +0200
committerJonas Schnelli <dev@jonasschnelli.ch>2020-05-13 10:13:06 +0200
commit8d17f8dc17732c16344dfd035207ce095a403d6e (patch)
tree6e532e4505dd07d7da1fe8d0cdf35b5c5fbb1970 /src
parent219c55da752dc48dd885c895f3998f3bc263fd93 (diff)
parente8123eae40eb264bbb71007d0eb074901f0e2fe5 (diff)
Merge #18578: gui: Fix leak in CoinControlDialog::updateView
e8123eae40eb264bbb71007d0eb074901f0e2fe5 gui: Fix itemWalletAddress leak when not tree mode (João Barbosa) Pull request description: Taken from #17457, the first commit is a similar to 88a94f7bb8ba2b0257315d70717f9af928ca6561 but for test binary, and the second commit fixes a leak where `CCoinControlWidgetItem` are unnecessarily created and leaked. ACKs for top commit: jonasschnelli: utACK e8123eae40eb264bbb71007d0eb074901f0e2fe5 hebasto: ACK e8123eae40eb264bbb71007d0eb074901f0e2fe5, tested on Linux Mint 19.3. Tree-SHA512: 8b43cb29de103842ce5f048de51222919540d3212d2873c16731145e856178644041924ad0e9a58c2ff08f209a9b4ac26dc9965289eb719da233c0984f93631e
Diffstat (limited to 'src')
-rw-r--r--src/qt/coincontroldialog.cpp5
-rw-r--r--src/qt/coincontroldialog.h1
2 files changed, 2 insertions, 4 deletions
diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp
index b46f416b6c..af7940cd29 100644
--- a/src/qt/coincontroldialog.cpp
+++ b/src/qt/coincontroldialog.cpp
@@ -606,8 +606,7 @@ void CoinControlDialog::updateView()
int nDisplayUnit = model->getOptionsModel()->getDisplayUnit();
for (const auto& coins : model->wallet().listCoins()) {
- CCoinControlWidgetItem *itemWalletAddress = new CCoinControlWidgetItem();
- itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked);
+ CCoinControlWidgetItem* itemWalletAddress{nullptr};
QString sWalletAddress = QString::fromStdString(EncodeDestination(coins.first));
QString sWalletLabel = model->getAddressTableModel()->labelForAddress(sWalletAddress);
if (sWalletLabel.isEmpty())
@@ -616,7 +615,7 @@ void CoinControlDialog::updateView()
if (treeMode)
{
// wallet address
- ui->treeWidget->addTopLevelItem(itemWalletAddress);
+ itemWalletAddress = new CCoinControlWidgetItem(ui->treeWidget);
itemWalletAddress->setFlags(flgTristate);
itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked);
diff --git a/src/qt/coincontroldialog.h b/src/qt/coincontroldialog.h
index eebab34a9d..25557fa6fe 100644
--- a/src/qt/coincontroldialog.h
+++ b/src/qt/coincontroldialog.h
@@ -31,7 +31,6 @@ class CCoinControlWidgetItem : public QTreeWidgetItem
{
public:
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) {}
bool operator<(const QTreeWidgetItem &other) const override;