Fix some memory leaks.

Memory leaks were caused by broken parent/child relations.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Boris Barbulovski 2014-01-15 18:52:42 +01:00 committed by Dirk Hohndel
parent a27f67c026
commit 6cc65f5e1c
11 changed files with 18 additions and 15 deletions

View file

@ -25,9 +25,9 @@
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false),
sortColumn(0), currentOrder(Qt::DescendingOrder), searchBox(new QLineEdit(this))
{
setItemDelegate(new DiveListDelegate );
setItemDelegate(new DiveListDelegate(this));
setUniformRowHeights(true);
setItemDelegateForColumn(DiveTripModel::RATING, new StarWidgetsDelegate());
setItemDelegateForColumn(DiveTripModel::RATING, new StarWidgetsDelegate(this));
QSortFilterProxyModel *model = new QSortFilterProxyModel(this);
model->setSortRole(DiveTripModel::SORT_ROLE);
model->setFilterKeyColumn(-1); // filter all columns

View file

@ -960,7 +960,7 @@ DivePlannerWidget::DivePlannerWidget(QWidget* parent, Qt::WindowFlags f): QWidge
view->setColumnHidden(CylindersModel::START, true);
view->setColumnHidden(CylindersModel::END, true);
view->setColumnHidden(CylindersModel::DEPTH, false);
view->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate());
view->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate(this));
connect(ui.cylinderTableWidget, SIGNAL(addButtonClicked()), DivePlannerPointsModel::instance(), SLOT(addCylinder_clicked()));
connect(ui.tableWidget, SIGNAL(addButtonClicked()), DivePlannerPointsModel::instance(), SLOT(addStop()));

View file

@ -68,7 +68,7 @@ GlobeGPS::GlobeGPS(QWidget* parent) : MarbleWidget(parent), loadedDives(0), edit
setMinimumHeight(0);
setMinimumWidth(0);
fixZoomTimer = new QTimer();
fixZoomTimer = new QTimer(this);
connect(fixZoomTimer, SIGNAL(timeout()), this, SLOT(fixZoom()));
fixZoomTimer->setSingleShot(true);
installEventFilter(this);

View file

@ -26,7 +26,7 @@
#include <QScrollBar>
MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
weightModel(new WeightModel()),
weightModel(new WeightModel(this)),
cylindersModel(CylindersModel::instance()),
editMode(NONE)
{
@ -83,8 +83,8 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
connect(ui.cylinders->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editCylinderWidget(QModelIndex)));
connect(ui.weights->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editWeightWidget(QModelIndex)));
ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate());
ui.weights->view()->setItemDelegateForColumn(WeightModel::TYPE, new WSInfoDelegate());
ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate(this));
ui.weights->view()->setItemDelegateForColumn(WeightModel::TYPE, new WSInfoDelegate(this));
ui.cylinders->view()->setColumnHidden(CylindersModel::DEPTH, true);
completers.buddy = new QCompleter(BuddyCompletionModel::instance(), ui.buddy);
completers.divemaster = new QCompleter(DiveMasterCompletionModel::instance(), ui.divemaster);

View file

@ -170,7 +170,10 @@ void MainWindow::on_actionClose_triggered()
/* clear the selection and the statistics */
selected_dive = -1;
existing_filename = NULL;
if (existing_filename) {
free((void *)existing_filename);
existing_filename = NULL;
}
cleanUpEmpty();
mark_divelist_changed(false);

View file

@ -7,7 +7,7 @@ class QPainter;
class DiveListDelegate : public QStyledItemDelegate{
public:
DiveListDelegate(){}
explicit DiveListDelegate(QObject *parent = 0): QStyledItemDelegate(parent){}
QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const;
};

View file

@ -31,7 +31,7 @@ QFont defaultModelFont()
return font;
}
CleanerTableModel::CleanerTableModel(): QAbstractTableModel()
CleanerTableModel::CleanerTableModel(QObject *parent): QAbstractTableModel(parent)
{
}
@ -343,7 +343,7 @@ void CylindersModel::remove(const QModelIndex& index)
endRemoveRows();
}
WeightModel::WeightModel(QObject* parent): current(0), rows(0)
WeightModel::WeightModel(QObject* parent): CleanerTableModel(parent), current(0), rows(0)
{
//enum Column {REMOVE, TYPE, WEIGHT};
setHeaderDataStrings(QStringList() << tr("") << tr("Type") << tr("Weight"));

View file

@ -22,7 +22,7 @@ QFont defaultModelFont();
class CleanerTableModel : public QAbstractTableModel{
Q_OBJECT
public:
CleanerTableModel();
explicit CleanerTableModel(QObject *parent = 0);
virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
protected:

View file

@ -265,7 +265,7 @@ QTableView *PrintLayout::createProfileTable(ProfilePrintModel *model, const int
// resize
table->resize(tableW, profilePrintTableMaxH);
// hide the grid and set a stylesheet
table->setItemDelegate(new ProfilePrintDelegate());
table->setItemDelegate(new ProfilePrintDelegate(this));
table->setShowGrid(false);
table->setStyleSheet(
"QTableView { border: none }"

View file

@ -60,7 +60,7 @@ ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent
rulerEnabled = false;
gc.printer = false;
fill_profile_color();
setScene(new QGraphicsScene());
setScene(new QGraphicsScene(this));
scene()->installEventFilter(this);

View file

@ -11,7 +11,7 @@
TableView::TableView(QWidget *parent) : QWidget(parent)
{
ui.setupUi(this);
ui.tableView->setItemDelegate(new DiveListDelegate);
ui.tableView->setItemDelegate(new DiveListDelegate(this));
/* There`s mostly a need for a Mac fix here too. */
if (qApp->style()->objectName() == "gtk+")
ui.groupBox->layout()->setContentsMargins(0, 9, 0, 0);