diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-10-23 19:40:41 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-10-29 00:09:31 +0000 |
commit | 64f0902e0d78ecf9a23016f8048c4e21167b527a (patch) | |
tree | ebf9a1d6f1d2d7f643344a08ecb55f408eef323f /desktop-widgets/locationinformation.cpp | |
parent | f527a70831a37e736431baa5705c9d188fc12f4b (diff) | |
download | subsurface-64f0902e0d78ecf9a23016f8048c4e21167b527a.tar.gz |
Dive site: pass dive-site pointers to merge_dive_sites()
Instead of passing uuids, pass a pointer to the dive site.
This is small step in an effort to remove uuids.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/locationinformation.cpp')
-rw-r--r-- | desktop-widgets/locationinformation.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp index 9d3eccb02..e24da5f7f 100644 --- a/desktop-widgets/locationinformation.cpp +++ b/desktop-widgets/locationinformation.cpp @@ -80,17 +80,18 @@ void LocationInformationWidget::mergeSelectedDiveSites() return; QModelIndexList selection = ui.diveSiteListView->selectionModel()->selectedIndexes(); - uint32_t *selected_dive_sites = (uint32_t *)malloc(sizeof(uint32_t) * selection.count()); - int i = 0; + // std::vector guarantees contiguous storage and can therefore be passed to C-code + std::vector<struct dive_site *> selected_dive_sites; + selected_dive_sites.reserve(selection.count()); Q_FOREACH (const QModelIndex &idx, selection) { - selected_dive_sites[i] = (uint32_t)idx.data(LocationInformationModel::UUID_ROLE).toInt(); - i++; + struct dive_site *ds = get_dive_site_by_uuid(idx.data(LocationInformationModel::UUID_ROLE).toUInt()); + if (ds) + selected_dive_sites.push_back(ds); } - merge_dive_sites(diveSite->uuid, selected_dive_sites, i); + merge_dive_sites(diveSite, selected_dive_sites.data(), (int)selected_dive_sites.size()); LocationInformationModel::instance()->update(); QSortFilterProxyModel *m = (QSortFilterProxyModel *)ui.diveSiteListView->model(); m->invalidate(); - free(selected_dive_sites); } void LocationInformationWidget::updateLabels() |