summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-models/divetripmodel.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp
index ae7641ba2..7a76ffbdb 100644
--- a/qt-models/divetripmodel.cpp
+++ b/qt-models/divetripmodel.cpp
@@ -696,12 +696,13 @@ void DiveTripModel::topLevelChanged(int idx)
// If that didn't change, try to move forward
if (newIdx == idx) {
- while (newIdx <= (int)items.size() && !dive_or_trip_less_than(items[idx].d_or_t, items[newIdx + 1].d_or_t))
+ ++newIdx;
+ while (newIdx < (int)items.size() && !dive_or_trip_less_than(items[idx].d_or_t, items[newIdx].d_or_t))
++newIdx;
}
// If index changed, move items
- if (newIdx != idx) {
+ if (newIdx != idx && newIdx != idx + 1) {
beginMoveRows(QModelIndex(), idx, idx, QModelIndex(), newIdx);
moveInVector(items, idx, idx + 1, newIdx);
endMoveRows();