diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2017-12-20 20:00:26 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-12-24 11:04:10 -0800 |
commit | 130f109442de7b5b047cc10b0e4534169459d291 (patch) | |
tree | d10dfc4bafbabd6a2beb44d0d109ca8543974a5f | |
parent | 4c4222d61119e437b4b79e36903a5b357756de21 (diff) | |
download | subsurface-130f109442de7b5b047cc10b0e4534169459d291.tar.gz |
Remove superfluous QScopedPointer<>s in singletons
There was a curious pattern of singletons being implemented based on
QScopedPointer<>s. This is an unnecessary level of indirection:
The lifetime of the smart pointer is the same as that of the
pointed-to object. Therefore, replace these pointers by the respective
objects.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r-- | core/gettextfromc.cpp | 4 | ||||
-rw-r--r-- | qt-models/cylindermodel.cpp | 4 | ||||
-rw-r--r-- | qt-models/diveplannermodel.cpp | 4 | ||||
-rw-r--r-- | qt-models/models.cpp | 4 | ||||
-rw-r--r-- | qt-models/tankinfomodel.cpp | 4 | ||||
-rw-r--r-- | qt-models/weigthsysteminfomodel.cpp | 4 |
6 files changed, 12 insertions, 12 deletions
diff --git a/core/gettextfromc.cpp b/core/gettextfromc.cpp index 8d1bbc1bd..e668fec2e 100644 --- a/core/gettextfromc.cpp +++ b/core/gettextfromc.cpp @@ -18,8 +18,8 @@ void gettextFromC::reset(void) gettextFromC *gettextFromC::instance() { - static QScopedPointer<gettextFromC> self(new gettextFromC()); - return self.data(); + static gettextFromC self; + return &self; } extern "C" const char *trGettext(const char *text) diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp index 9f34007c7..e46048222 100644 --- a/qt-models/cylindermodel.cpp +++ b/qt-models/cylindermodel.cpp @@ -31,8 +31,8 @@ QVariant CylindersModel::headerData(int section, Qt::Orientation orientation, in CylindersModel *CylindersModel::instance() { - static QScopedPointer<CylindersModel> self(new CylindersModel()); - return self.data(); + static CylindersModel self; + return &self; } static QString get_cylinder_string(cylinder_t *cyl) diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index 82aeda388..1d3e3347e 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -412,8 +412,8 @@ DivePlannerPointsModel::DivePlannerPointsModel(QObject *parent) : QAbstractTable DivePlannerPointsModel *DivePlannerPointsModel::instance() { - static QScopedPointer<DivePlannerPointsModel> self(new DivePlannerPointsModel()); - return self.data(); + static DivePlannerPointsModel self; + return &self; } void DivePlannerPointsModel::emitDataChanged() diff --git a/qt-models/models.cpp b/qt-models/models.cpp index fa9519600..4f4df6425 100644 --- a/qt-models/models.cpp +++ b/qt-models/models.cpp @@ -32,8 +32,8 @@ Qt::ItemFlags GasSelectionModel::flags(const QModelIndex &index) const GasSelectionModel *GasSelectionModel::instance() { - static QScopedPointer<GasSelectionModel> self(new GasSelectionModel()); - return self.data(); + static GasSelectionModel self; + return &self; } //TODO: Remove this #include here when the issue below is fixed. diff --git a/qt-models/tankinfomodel.cpp b/qt-models/tankinfomodel.cpp index 97f0e8010..d2644a16b 100644 --- a/qt-models/tankinfomodel.cpp +++ b/qt-models/tankinfomodel.cpp @@ -6,8 +6,8 @@ TankInfoModel *TankInfoModel::instance() { - static QScopedPointer<TankInfoModel> self(new TankInfoModel()); - return self.data(); + static TankInfoModel self; + return &self; } const QString &TankInfoModel::biggerString() const diff --git a/qt-models/weigthsysteminfomodel.cpp b/qt-models/weigthsysteminfomodel.cpp index fe912ed32..608a70e56 100644 --- a/qt-models/weigthsysteminfomodel.cpp +++ b/qt-models/weigthsysteminfomodel.cpp @@ -6,8 +6,8 @@ WSInfoModel *WSInfoModel::instance() { - static QScopedPointer<WSInfoModel> self(new WSInfoModel()); - return self.data(); + static WSInfoModel self; + return &self; } bool WSInfoModel::insertRows(int row, int count, const QModelIndex &parent) |