diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-06-15 21:30:49 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-06-17 06:53:13 +0900 |
commit | f54764cdbc877e6519a464cf2e31a3877a00bc66 (patch) | |
tree | 67ea12c4f49b65832c804f2b7b3e411815223027 | |
parent | 0bc9edf855caf95e2d58ccaf704ceeda079e06f1 (diff) | |
download | subsurface-f54764cdbc877e6519a464cf2e31a3877a00bc66.tar.gz |
Cleanup: use QScopedPointer for DiveComputerManagementDialog::model
Not necessary to do own memory management.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r-- | desktop-widgets/divecomputermanagementdialog.cpp | 8 | ||||
-rw-r--r-- | desktop-widgets/divecomputermanagementdialog.h | 4 |
2 files changed, 5 insertions, 7 deletions
diff --git a/desktop-widgets/divecomputermanagementdialog.cpp b/desktop-widgets/divecomputermanagementdialog.cpp index 5a54bc953..0ff358c22 100644 --- a/desktop-widgets/divecomputermanagementdialog.cpp +++ b/desktop-widgets/divecomputermanagementdialog.cpp @@ -6,8 +6,7 @@ #include <QMessageBox> #include <QShortcut> -DiveComputerManagementDialog::DiveComputerManagementDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f), - model(0) +DiveComputerManagementDialog::DiveComputerManagementDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) { ui.setupUi(this); init(); @@ -20,9 +19,8 @@ DiveComputerManagementDialog::DiveComputerManagementDialog(QWidget *parent, Qt:: void DiveComputerManagementDialog::init() { - delete model; - model = new DiveComputerModel(dcList.dcMap); - ui.tableView->setModel(model); + model.reset(new DiveComputerModel(dcList.dcMap)); + ui.tableView->setModel(model.data()); } DiveComputerManagementDialog *DiveComputerManagementDialog::instance() diff --git a/desktop-widgets/divecomputermanagementdialog.h b/desktop-widgets/divecomputermanagementdialog.h index 8c1c3c8a9..365a685d4 100644 --- a/desktop-widgets/divecomputermanagementdialog.h +++ b/desktop-widgets/divecomputermanagementdialog.h @@ -3,9 +3,9 @@ #define DIVECOMPUTERMANAGEMENTDIALOG_H #include <QDialog> #include "ui_divecomputermanagementdialog.h" +#include "qt-models/divecomputermodel.h" class QModelIndex; -class DiveComputerModel; class DiveComputerManagementDialog : public QDialog { Q_OBJECT @@ -24,7 +24,7 @@ slots: private: explicit DiveComputerManagementDialog(QWidget *parent = 0, Qt::WindowFlags f = 0); Ui::DiveComputerManagementDialog ui; - DiveComputerModel *model; + QScopedPointer<DiveComputerModel> model; }; #endif // DIVECOMPUTERMANAGEMENTDIALOG_H |