aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models/divepicturemodel.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-04-14 22:14:23 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-05-06 13:58:09 -0700
commitbd960ea088aebb19de9cdee455103e1878e2506f (patch)
treeabb109abf6e5656c48f38a7ee7da98829856906c /qt-models/divepicturemodel.cpp
parent0d06eb83d87302c235f682e95a767d4e37904ea6 (diff)
downloadsubsurface-bd960ea088aebb19de9cdee455103e1878e2506f.tar.gz
media: store dive instead of dive-id in DivePictureModel
dive-pointers are stable and the dive picture model is reset if a selected dive is removed, so there is no risk in keeping pointers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/divepicturemodel.cpp')
-rw-r--r--qt-models/divepicturemodel.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/qt-models/divepicturemodel.cpp b/qt-models/divepicturemodel.cpp
index 6272935de..548f8e7be 100644
--- a/qt-models/divepicturemodel.cpp
+++ b/qt-models/divepicturemodel.cpp
@@ -63,10 +63,10 @@ void DivePictureModel::updateDivePictures()
if (dive->selected) {
int first = pictures.count();
FOR_EACH_PICTURE(dive)
- pictures.push_back({ dive->id, picture->filename, {}, picture->offset.seconds, {.seconds = 0}});
+ pictures.push_back({ dive, picture->filename, {}, picture->offset.seconds, {.seconds = 0}});
// Sort pictures of this dive by offset.
- // Thus, the list will be sorted by (diveId, offset).
+ // Thus, the list will be sorted by (dive, offset).
std::sort(pictures.begin() + first, pictures.end(),
[](const PictureEntry &a, const PictureEntry &b) { return a.offsetSeconds < b.offsetSeconds; });
}
@@ -218,8 +218,8 @@ void DivePictureModel::pictureOffsetChanged(dive *d, const QString filenameIn, o
std::string filename = filenameIn.toStdString();
// Find the pictures of the given dive.
- auto from = std::find_if(pictures.begin(), pictures.end(), [d](const PictureEntry &e) { return e.diveId == d->id; });
- auto to = std::find_if(from, pictures.end(), [d](const PictureEntry &e) { return e.diveId != d->id; });
+ auto from = std::find_if(pictures.begin(), pictures.end(), [d](const PictureEntry &e) { return e.d == d; });
+ auto to = std::find_if(from, pictures.end(), [d](const PictureEntry &e) { return e.d != d; });
// Find picture with the given filename
auto oldPos = std::find_if(from, to, [filename](const PictureEntry &e) { return e.filename == filename; });