qt: Plug many memory leaks
None of these are very serious, and are leaks in objects that are created at most one time. In most cases this means properly using the QObject parent hierarchy, except for BanTablePriv/PeerTablePriv which are not QObject, so use a std::unique_ptr instead.
This commit is contained in:
parent
9346f84299
commit
47db075377
16 changed files with 40 additions and 26 deletions
|
@ -83,7 +83,7 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
|
||||||
deleteAction = new QAction(ui->deleteAddress->text(), this);
|
deleteAction = new QAction(ui->deleteAddress->text(), this);
|
||||||
|
|
||||||
// Build context menu
|
// Build context menu
|
||||||
contextMenu = new QMenu();
|
contextMenu = new QMenu(this);
|
||||||
contextMenu->addAction(copyAddressAction);
|
contextMenu->addAction(copyAddressAction);
|
||||||
contextMenu->addAction(copyLabelAction);
|
contextMenu->addAction(copyLabelAction);
|
||||||
contextMenu->addAction(editAction);
|
contextMenu->addAction(editAction);
|
||||||
|
|
|
@ -87,7 +87,7 @@ BanTableModel::BanTableModel(ClientModel *parent) :
|
||||||
clientModel(parent)
|
clientModel(parent)
|
||||||
{
|
{
|
||||||
columns << tr("IP/Netmask") << tr("Banned Until");
|
columns << tr("IP/Netmask") << tr("Banned Until");
|
||||||
priv = new BanTablePriv();
|
priv.reset(new BanTablePriv());
|
||||||
// default to unsorted
|
// default to unsorted
|
||||||
priv->sortColumn = -1;
|
priv->sortColumn = -1;
|
||||||
|
|
||||||
|
@ -95,6 +95,11 @@ BanTableModel::BanTableModel(ClientModel *parent) :
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BanTableModel::~BanTableModel()
|
||||||
|
{
|
||||||
|
// Intentionally left empty
|
||||||
|
}
|
||||||
|
|
||||||
int BanTableModel::rowCount(const QModelIndex &parent) const
|
int BanTableModel::rowCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
|
|
|
@ -40,6 +40,7 @@ class BanTableModel : public QAbstractTableModel
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BanTableModel(ClientModel *parent = 0);
|
explicit BanTableModel(ClientModel *parent = 0);
|
||||||
|
~BanTableModel();
|
||||||
void startAutoRefresh();
|
void startAutoRefresh();
|
||||||
void stopAutoRefresh();
|
void stopAutoRefresh();
|
||||||
|
|
||||||
|
@ -66,7 +67,7 @@ public Q_SLOTS:
|
||||||
private:
|
private:
|
||||||
ClientModel *clientModel;
|
ClientModel *clientModel;
|
||||||
QStringList columns;
|
QStringList columns;
|
||||||
BanTablePriv *priv;
|
std::unique_ptr<BanTablePriv> priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BITCOIN_QT_BANTABLEMODEL_H
|
#endif // BITCOIN_QT_BANTABLEMODEL_H
|
||||||
|
|
|
@ -1185,7 +1185,7 @@ void UnitDisplayStatusBarControl::mousePressEvent(QMouseEvent *event)
|
||||||
/** Creates context menu, its actions, and wires up all the relevant signals for mouse events. */
|
/** Creates context menu, its actions, and wires up all the relevant signals for mouse events. */
|
||||||
void UnitDisplayStatusBarControl::createContextMenu()
|
void UnitDisplayStatusBarControl::createContextMenu()
|
||||||
{
|
{
|
||||||
menu = new QMenu();
|
menu = new QMenu(this);
|
||||||
Q_FOREACH(BitcoinUnits::Unit u, BitcoinUnits::availableUnits())
|
Q_FOREACH(BitcoinUnits::Unit u, BitcoinUnits::availableUnits())
|
||||||
{
|
{
|
||||||
QAction *menuAction = new QAction(QString(BitcoinUnits::name(u)), this);
|
QAction *menuAction = new QAction(QString(BitcoinUnits::name(u)), this);
|
||||||
|
|
|
@ -52,7 +52,7 @@ CoinControlDialog::CoinControlDialog(const PlatformStyle *_platformStyle, QWidge
|
||||||
unlockAction = new QAction(tr("Unlock unspent"), this); // we need to enable/disable this
|
unlockAction = new QAction(tr("Unlock unspent"), this); // we need to enable/disable this
|
||||||
|
|
||||||
// context menu
|
// context menu
|
||||||
contextMenu = new QMenu();
|
contextMenu = new QMenu(this);
|
||||||
contextMenu->addAction(copyAddressAction);
|
contextMenu->addAction(copyAddressAction);
|
||||||
contextMenu->addAction(copyLabelAction);
|
contextMenu->addAction(copyLabelAction);
|
||||||
contextMenu->addAction(copyAmountAction);
|
contextMenu->addAction(copyAmountAction);
|
||||||
|
|
|
@ -585,7 +585,8 @@ void TableViewLastColumnResizingFixer::on_geometriesChanged()
|
||||||
* Initializes all internal variables and prepares the
|
* Initializes all internal variables and prepares the
|
||||||
* the resize modes of the last 2 columns of the table and
|
* the resize modes of the last 2 columns of the table and
|
||||||
*/
|
*/
|
||||||
TableViewLastColumnResizingFixer::TableViewLastColumnResizingFixer(QTableView* table, int lastColMinimumWidth, int allColsMinimumWidth) :
|
TableViewLastColumnResizingFixer::TableViewLastColumnResizingFixer(QTableView* table, int lastColMinimumWidth, int allColsMinimumWidth, QObject *parent) :
|
||||||
|
QObject(parent),
|
||||||
tableView(table),
|
tableView(table),
|
||||||
lastColumnMinimumWidth(lastColMinimumWidth),
|
lastColumnMinimumWidth(lastColMinimumWidth),
|
||||||
allColumnsMinimumWidth(allColsMinimumWidth)
|
allColumnsMinimumWidth(allColsMinimumWidth)
|
||||||
|
|
|
@ -149,7 +149,7 @@ namespace GUIUtil
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TableViewLastColumnResizingFixer(QTableView* table, int lastColMinimumWidth, int allColsMinimumWidth);
|
TableViewLastColumnResizingFixer(QTableView* table, int lastColMinimumWidth, int allColsMinimumWidth, QObject *parent);
|
||||||
void stretchColumnWidth(int column);
|
void stretchColumnWidth(int column);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -25,8 +25,8 @@ class TxViewDelegate : public QAbstractItemDelegate
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TxViewDelegate(const PlatformStyle *_platformStyle):
|
TxViewDelegate(const PlatformStyle *_platformStyle, QObject *parent=nullptr):
|
||||||
QAbstractItemDelegate(), unit(BitcoinUnits::BTC),
|
QAbstractItemDelegate(parent), unit(BitcoinUnits::BTC),
|
||||||
platformStyle(_platformStyle)
|
platformStyle(_platformStyle)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -119,8 +119,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent)
|
||||||
currentWatchOnlyBalance(-1),
|
currentWatchOnlyBalance(-1),
|
||||||
currentWatchUnconfBalance(-1),
|
currentWatchUnconfBalance(-1),
|
||||||
currentWatchImmatureBalance(-1),
|
currentWatchImmatureBalance(-1),
|
||||||
txdelegate(new TxViewDelegate(platformStyle)),
|
txdelegate(new TxViewDelegate(platformStyle, this))
|
||||||
filter(0)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -220,7 +219,7 @@ void OverviewPage::setWalletModel(WalletModel *model)
|
||||||
if(model && model->getOptionsModel())
|
if(model && model->getOptionsModel())
|
||||||
{
|
{
|
||||||
// Set up transaction list
|
// Set up transaction list
|
||||||
filter = new TransactionFilterProxy();
|
filter.reset(new TransactionFilterProxy());
|
||||||
filter->setSourceModel(model->getTransactionTableModel());
|
filter->setSourceModel(model->getTransactionTableModel());
|
||||||
filter->setLimit(NUM_ITEMS);
|
filter->setLimit(NUM_ITEMS);
|
||||||
filter->setDynamicSortFilter(true);
|
filter->setDynamicSortFilter(true);
|
||||||
|
@ -228,7 +227,7 @@ void OverviewPage::setWalletModel(WalletModel *model)
|
||||||
filter->setShowInactive(false);
|
filter->setShowInactive(false);
|
||||||
filter->sort(TransactionTableModel::Date, Qt::DescendingOrder);
|
filter->sort(TransactionTableModel::Date, Qt::DescendingOrder);
|
||||||
|
|
||||||
ui->listTransactions->setModel(filter);
|
ui->listTransactions->setModel(filter.get());
|
||||||
ui->listTransactions->setModelColumn(TransactionTableModel::ToAddress);
|
ui->listTransactions->setModelColumn(TransactionTableModel::ToAddress);
|
||||||
|
|
||||||
// Keep up to date with wallet
|
// Keep up to date with wallet
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "amount.h"
|
#include "amount.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class ClientModel;
|
class ClientModel;
|
||||||
class TransactionFilterProxy;
|
class TransactionFilterProxy;
|
||||||
|
@ -56,7 +57,7 @@ private:
|
||||||
CAmount currentWatchImmatureBalance;
|
CAmount currentWatchImmatureBalance;
|
||||||
|
|
||||||
TxViewDelegate *txdelegate;
|
TxViewDelegate *txdelegate;
|
||||||
TransactionFilterProxy *filter;
|
std::unique_ptr<TransactionFilterProxy> filter;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void updateDisplayUnit();
|
void updateDisplayUnit();
|
||||||
|
|
|
@ -114,12 +114,12 @@ PeerTableModel::PeerTableModel(ClientModel *parent) :
|
||||||
timer(0)
|
timer(0)
|
||||||
{
|
{
|
||||||
columns << tr("NodeId") << tr("Node/Service") << tr("User Agent") << tr("Ping");
|
columns << tr("NodeId") << tr("Node/Service") << tr("User Agent") << tr("Ping");
|
||||||
priv = new PeerTablePriv();
|
priv.reset(new PeerTablePriv());
|
||||||
// default to unsorted
|
// default to unsorted
|
||||||
priv->sortColumn = -1;
|
priv->sortColumn = -1;
|
||||||
|
|
||||||
// set up timer for auto refresh
|
// set up timer for auto refresh
|
||||||
timer = new QTimer();
|
timer = new QTimer(this);
|
||||||
connect(timer, SIGNAL(timeout()), SLOT(refresh()));
|
connect(timer, SIGNAL(timeout()), SLOT(refresh()));
|
||||||
timer->setInterval(MODEL_UPDATE_DELAY);
|
timer->setInterval(MODEL_UPDATE_DELAY);
|
||||||
|
|
||||||
|
@ -127,6 +127,11 @@ PeerTableModel::PeerTableModel(ClientModel *parent) :
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PeerTableModel::~PeerTableModel()
|
||||||
|
{
|
||||||
|
// Intentionally left empty
|
||||||
|
}
|
||||||
|
|
||||||
void PeerTableModel::startAutoRefresh()
|
void PeerTableModel::startAutoRefresh()
|
||||||
{
|
{
|
||||||
timer->start();
|
timer->start();
|
||||||
|
|
|
@ -46,6 +46,7 @@ class PeerTableModel : public QAbstractTableModel
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PeerTableModel(ClientModel *parent = 0);
|
explicit PeerTableModel(ClientModel *parent = 0);
|
||||||
|
~PeerTableModel();
|
||||||
const CNodeCombinedStats *getNodeStats(int idx);
|
const CNodeCombinedStats *getNodeStats(int idx);
|
||||||
int getRowByNodeId(NodeId nodeid);
|
int getRowByNodeId(NodeId nodeid);
|
||||||
void startAutoRefresh();
|
void startAutoRefresh();
|
||||||
|
@ -75,7 +76,7 @@ public Q_SLOTS:
|
||||||
private:
|
private:
|
||||||
ClientModel *clientModel;
|
ClientModel *clientModel;
|
||||||
QStringList columns;
|
QStringList columns;
|
||||||
PeerTablePriv *priv;
|
std::unique_ptr<PeerTablePriv> priv;
|
||||||
QTimer *timer;
|
QTimer *timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
ReceiveCoinsDialog::ReceiveCoinsDialog(const PlatformStyle *_platformStyle, QWidget *parent) :
|
ReceiveCoinsDialog::ReceiveCoinsDialog(const PlatformStyle *_platformStyle, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::ReceiveCoinsDialog),
|
ui(new Ui::ReceiveCoinsDialog),
|
||||||
|
columnResizingFixer(0),
|
||||||
model(0),
|
model(0),
|
||||||
platformStyle(_platformStyle)
|
platformStyle(_platformStyle)
|
||||||
{
|
{
|
||||||
|
@ -49,7 +50,7 @@ ReceiveCoinsDialog::ReceiveCoinsDialog(const PlatformStyle *_platformStyle, QWid
|
||||||
QAction *copyAmountAction = new QAction(tr("Copy amount"), this);
|
QAction *copyAmountAction = new QAction(tr("Copy amount"), this);
|
||||||
|
|
||||||
// context menu
|
// context menu
|
||||||
contextMenu = new QMenu();
|
contextMenu = new QMenu(this);
|
||||||
contextMenu->addAction(copyURIAction);
|
contextMenu->addAction(copyURIAction);
|
||||||
contextMenu->addAction(copyLabelAction);
|
contextMenu->addAction(copyLabelAction);
|
||||||
contextMenu->addAction(copyMessageAction);
|
contextMenu->addAction(copyMessageAction);
|
||||||
|
@ -91,7 +92,7 @@ void ReceiveCoinsDialog::setModel(WalletModel *_model)
|
||||||
SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this,
|
SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this,
|
||||||
SLOT(recentRequestsView_selectionChanged(QItemSelection, QItemSelection)));
|
SLOT(recentRequestsView_selectionChanged(QItemSelection, QItemSelection)));
|
||||||
// Last 2 columns are set by the columnResizingFixer, when the table geometry is ready.
|
// Last 2 columns are set by the columnResizingFixer, when the table geometry is ready.
|
||||||
columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(tableView, AMOUNT_MINIMUM_COLUMN_WIDTH, DATE_COLUMN_WIDTH);
|
columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(tableView, AMOUNT_MINIMUM_COLUMN_WIDTH, DATE_COLUMN_WIDTH, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
QRImageWidget::QRImageWidget(QWidget *parent):
|
QRImageWidget::QRImageWidget(QWidget *parent):
|
||||||
QLabel(parent), contextMenu(0)
|
QLabel(parent), contextMenu(0)
|
||||||
{
|
{
|
||||||
contextMenu = new QMenu();
|
contextMenu = new QMenu(this);
|
||||||
QAction *saveImageAction = new QAction(tr("&Save Image..."), this);
|
QAction *saveImageAction = new QAction(tr("&Save Image..."), this);
|
||||||
connect(saveImageAction, SIGNAL(triggered()), this, SLOT(saveImage()));
|
connect(saveImageAction, SIGNAL(triggered()), this, SLOT(saveImage()));
|
||||||
contextMenu->addAction(saveImageAction);
|
contextMenu->addAction(saveImageAction);
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
RecentRequestsTableModel::RecentRequestsTableModel(CWallet *wallet, WalletModel *parent) :
|
RecentRequestsTableModel::RecentRequestsTableModel(CWallet *wallet, WalletModel *parent) :
|
||||||
walletModel(parent)
|
QAbstractTableModel(parent), walletModel(parent)
|
||||||
{
|
{
|
||||||
Q_UNUSED(wallet);
|
Q_UNUSED(wallet);
|
||||||
nReceiveRequestsMaxId = 0;
|
nReceiveRequestsMaxId = 0;
|
||||||
|
|
|
@ -486,7 +486,7 @@ void RPCConsole::setClientModel(ClientModel *model)
|
||||||
QAction* banAction365d = new QAction(tr("Ban for") + " " + tr("1 &year"), this);
|
QAction* banAction365d = new QAction(tr("Ban for") + " " + tr("1 &year"), this);
|
||||||
|
|
||||||
// create peer table context menu
|
// create peer table context menu
|
||||||
peersTableContextMenu = new QMenu();
|
peersTableContextMenu = new QMenu(this);
|
||||||
peersTableContextMenu->addAction(disconnectAction);
|
peersTableContextMenu->addAction(disconnectAction);
|
||||||
peersTableContextMenu->addAction(banAction1h);
|
peersTableContextMenu->addAction(banAction1h);
|
||||||
peersTableContextMenu->addAction(banAction24h);
|
peersTableContextMenu->addAction(banAction24h);
|
||||||
|
@ -534,7 +534,7 @@ void RPCConsole::setClientModel(ClientModel *model)
|
||||||
QAction* unbanAction = new QAction(tr("&Unban"), this);
|
QAction* unbanAction = new QAction(tr("&Unban"), this);
|
||||||
|
|
||||||
// create ban table context menu
|
// create ban table context menu
|
||||||
banTableContextMenu = new QMenu();
|
banTableContextMenu = new QMenu(this);
|
||||||
banTableContextMenu->addAction(unbanAction);
|
banTableContextMenu->addAction(unbanAction);
|
||||||
|
|
||||||
// ban table context menu signals
|
// ban table context menu signals
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *parent) :
|
TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *parent) :
|
||||||
QWidget(parent), model(0), transactionProxyModel(0),
|
QWidget(parent), model(0), transactionProxyModel(0),
|
||||||
transactionView(0), abandonAction(0)
|
transactionView(0), abandonAction(0), columnResizingFixer(0)
|
||||||
{
|
{
|
||||||
// Build filter row
|
// Build filter row
|
||||||
setContentsMargins(0,0,0,0);
|
setContentsMargins(0,0,0,0);
|
||||||
|
@ -147,7 +147,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
|
||||||
QAction *editLabelAction = new QAction(tr("Edit label"), this);
|
QAction *editLabelAction = new QAction(tr("Edit label"), this);
|
||||||
QAction *showDetailsAction = new QAction(tr("Show transaction details"), this);
|
QAction *showDetailsAction = new QAction(tr("Show transaction details"), this);
|
||||||
|
|
||||||
contextMenu = new QMenu();
|
contextMenu = new QMenu(this);
|
||||||
contextMenu->addAction(copyAddressAction);
|
contextMenu->addAction(copyAddressAction);
|
||||||
contextMenu->addAction(copyLabelAction);
|
contextMenu->addAction(copyLabelAction);
|
||||||
contextMenu->addAction(copyAmountAction);
|
contextMenu->addAction(copyAmountAction);
|
||||||
|
@ -212,7 +212,7 @@ void TransactionView::setModel(WalletModel *_model)
|
||||||
transactionView->setColumnWidth(TransactionTableModel::Type, TYPE_COLUMN_WIDTH);
|
transactionView->setColumnWidth(TransactionTableModel::Type, TYPE_COLUMN_WIDTH);
|
||||||
transactionView->setColumnWidth(TransactionTableModel::Amount, AMOUNT_MINIMUM_COLUMN_WIDTH);
|
transactionView->setColumnWidth(TransactionTableModel::Amount, AMOUNT_MINIMUM_COLUMN_WIDTH);
|
||||||
|
|
||||||
columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(transactionView, AMOUNT_MINIMUM_COLUMN_WIDTH, MINIMUM_COLUMN_WIDTH);
|
columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(transactionView, AMOUNT_MINIMUM_COLUMN_WIDTH, MINIMUM_COLUMN_WIDTH, this);
|
||||||
|
|
||||||
if (_model->getOptionsModel())
|
if (_model->getOptionsModel())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue