diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-10-28 21:16:42 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-10-29 00:09:31 +0000 |
commit | 920eb7576ff3c5fab19c12b7b291042817422ac5 (patch) | |
tree | 10af74e93306ea0e3577b30ea9704545185462e6 /qt-models/divelocationmodel.cpp | |
parent | e8b3fdb4a6936c1130395e039963839d64f2b396 (diff) | |
download | subsurface-920eb7576ff3c5fab19c12b7b291042817422ac5.tar.gz |
Dive site: pass pointer-to-dive_site via QVariant
There was this ugly pattern of passing pointers-to-dive_site via
a QVariant of void * type. This is of course inherently unsafe.
Pass these pointers using their proper types instead. This makes
it necessary to register them in Qt's meta-type system. Doing so,
fixes a bug: QML couldn't call into updateDiveSiteCoordinates()
because it didn't know the type and thus the coordinates of
the moved flag were not reflected in the divesite-dialog.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/divelocationmodel.cpp')
-rw-r--r-- | qt-models/divelocationmodel.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp index 18be89806..b84604bb5 100644 --- a/qt-models/divelocationmodel.cpp +++ b/qt-models/divelocationmodel.cpp @@ -41,7 +41,7 @@ QVariant LocationInformationModel::getDiveSiteData(const struct dive_site *ds, i case Qt::EditRole: case Qt::DisplayRole : switch(column) { - case DIVESITE: return QVariant::fromValue<void*>((void *)ds); // Not nice: casting away const + case DIVESITE: return QVariant::fromValue<dive_site *>((dive_site *)ds); // Not nice: casting away const case NAME: return ds->name; case LATITUDE: return ds->location.lat.udeg; case LONGITUDE: return ds->location.lon.udeg; @@ -60,7 +60,7 @@ QVariant LocationInformationModel::getDiveSiteData(const struct dive_site *ds, i return QVariant(); } case DIVESITE_ROLE: - return QVariant::fromValue<void *>((void *)ds); // Not nice: casting away const + return QVariant::fromValue<dive_site *>((dive_site *)ds); // Not nice: casting away const } return QVariant(); } @@ -119,7 +119,7 @@ GeoReferencingOptionsModel::GeoReferencingOptionsModel(QObject *parent) : QStrin bool GPSLocationInformationModel::filterAcceptsRow(int sourceRow, const QModelIndex &parent) const { - struct dive_site *ds = (struct dive_site *)sourceModel()->index(sourceRow, LocationInformationModel::DIVESITE, parent).data().value<void *>(); + struct dive_site *ds = sourceModel()->index(sourceRow, LocationInformationModel::DIVESITE, parent).data().value<dive_site *>(); if (ds == ignoreDs || ds == RECENTLY_ADDED_DIVESITE) return false; |