mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
e8b3fdb4a6
commit
920eb7576f
5 changed files with 11 additions and 8 deletions
|
@ -82,7 +82,7 @@ void LocationInformationWidget::mergeSelectedDiveSites()
|
|||
std::vector<struct dive_site *> selected_dive_sites;
|
||||
selected_dive_sites.reserve(selection.count());
|
||||
Q_FOREACH (const QModelIndex &idx, selection) {
|
||||
struct dive_site *ds = (struct dive_site *)idx.data(LocationInformationModel::DIVESITE_ROLE).value<void *>();
|
||||
dive_site *ds = idx.data(LocationInformationModel::DIVESITE_ROLE).value<dive_site *>();
|
||||
if (ds)
|
||||
selected_dive_sites.push_back(ds);
|
||||
}
|
||||
|
@ -507,7 +507,7 @@ void DiveLocationLineEdit::itemActivated(const QModelIndex &index)
|
|||
if (index.column() == LocationInformationModel::DIVESITE)
|
||||
idx = index.model()->index(index.row(), LocationInformationModel::NAME);
|
||||
|
||||
dive_site *ds = (dive_site *)index.model()->index(index.row(), LocationInformationModel::DIVESITE).data().value<void *>();
|
||||
dive_site *ds = index.model()->index(index.row(), LocationInformationModel::DIVESITE).data().value<dive_site *>();
|
||||
currType = ds == RECENTLY_ADDED_DIVESITE ? NEW_DIVE_SITE : EXISTING_DIVE_SITE;
|
||||
currDs = ds;
|
||||
setText(idx.data().toString());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue