summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Boris Barbulovski <bbarbulovski@gmail.com>2014-01-15 18:52:42 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-16 12:15:47 +0700
commit6cc65f5e1cf1eb0c870323d4c19e2d5c9cc9fd11 (patch)
tree424ad29366d0ac0a09be8540b365342aca7f27dd /qt-ui
parenta27f67c02612791fad73b4e0550d942dc3a5a339 (diff)
downloadsubsurface-6cc65f5e1cf1eb0c870323d4c19e2d5c9cc9fd11.tar.gz
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>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/divelistview.cpp4
-rw-r--r--qt-ui/diveplanner.cpp2
-rw-r--r--qt-ui/globe.cpp2
-rw-r--r--qt-ui/maintab.cpp6
-rw-r--r--qt-ui/mainwindow.cpp5
-rw-r--r--qt-ui/modeldelegates.h2
-rw-r--r--qt-ui/models.cpp4
-rw-r--r--qt-ui/models.h2
-rw-r--r--qt-ui/printlayout.cpp2
-rw-r--r--qt-ui/profilegraphics.cpp2
-rw-r--r--qt-ui/tableview.cpp2
11 files changed, 18 insertions, 15 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index b26fdf393..86a3b95fd 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -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
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 166de8308..7fa1a8783 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -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()));
diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp
index 4bc946131..2aed8d4a1 100644
--- a/qt-ui/globe.cpp
+++ b/qt-ui/globe.cpp
@@ -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);
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index b8b53e998..63cbd6181 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -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);
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 8ebc67413..d2b208ed0 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -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);
diff --git a/qt-ui/modeldelegates.h b/qt-ui/modeldelegates.h
index 013a1c17a..72f75b0da 100644
--- a/qt-ui/modeldelegates.h
+++ b/qt-ui/modeldelegates.h
@@ -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;
};
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index cddd4ed2e..06bb95281 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -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"));
diff --git a/qt-ui/models.h b/qt-ui/models.h
index 16818e407..2d7e5c34d 100644
--- a/qt-ui/models.h
+++ b/qt-ui/models.h
@@ -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:
diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp
index b058bbc7d..c76068769 100644
--- a/qt-ui/printlayout.cpp
+++ b/qt-ui/printlayout.cpp
@@ -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 }"
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp
index 3c481ee2a..c907d2529 100644
--- a/qt-ui/profilegraphics.cpp
+++ b/qt-ui/profilegraphics.cpp
@@ -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);
diff --git a/qt-ui/tableview.cpp b/qt-ui/tableview.cpp
index 93711ded1..6bb1944b8 100644
--- a/qt-ui/tableview.cpp
+++ b/qt-ui/tableview.cpp
@@ -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);