From 2890be92568d36303e99e84501994572c2a16c6e Mon Sep 17 00:00:00 2001 From: Stefan Fuchs Date: Wed, 13 Dec 2017 19:32:29 +0100 Subject: divepicturemodel: Reset start and end row for displayed_dive correctly Correct way of using indices for rowDDstart and rowDDend. Reset rowDDstart and rowDDend at beginning of updating dive pictures. Signed-off-by: Stefan Fuchs --- profile-widget/profilewidget2.cpp | 2 +- qt-models/divepicturemodel.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index b40980e5f..b7b6057fe 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -2000,7 +2000,7 @@ void ProfileWidget2::plotPictures() double x, y, lastX = -1.0, lastY = -1.0; DivePictureModel *m = DivePictureModel::instance(); - for (int i = m->rowDDStart; i <= m->rowDDEnd; i++) { + for (int i = m->rowDDStart; i < m->rowDDEnd; i++) { int offsetSeconds = m->index(i, 1).data(Qt::UserRole).value(); // it's a correct picture, but doesn't have a timestamp: only show on the widget near the // information area. diff --git a/qt-models/divepicturemodel.cpp b/qt-models/divepicturemodel.cpp index 994eb674e..d886fd767 100644 --- a/qt-models/divepicturemodel.cpp +++ b/qt-models/divepicturemodel.cpp @@ -54,6 +54,7 @@ void DivePictureModel::updateDivePictures() beginRemoveRows(QModelIndex(), 0, pictures.count() - 1); pictures.clear(); endRemoveRows(); + rowDDStart = rowDDEnd = 0; } // if the dive_table is empty, quit @@ -69,7 +70,7 @@ void DivePictureModel::updateDivePictures() FOR_EACH_PICTURE(dive) pictures.push_back({picture, picture->filename, QImage(), picture->offset.seconds}); if (dive->id == displayed_dive.id) - rowDDEnd = pictures.count() - 1; + rowDDEnd = pictures.count(); } } QtConcurrent::blockingMap(pictures, scaleImages); -- cgit v1.2.3-70-g09d2