aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/divelistview.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index 502cebcbd..96b9291ac 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -325,11 +325,13 @@ void DiveListView::selectDives(const QList<int> &newDiveSelection)
selectDive(sortedSelection.takeLast());
QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel *>(model());
- QModelIndex idx = m->match(m->index(0, 0), DiveTripModel::DIVE_IDX, selected_dive, 2, Qt::MatchRecursive).first();
- if (idx.parent().isValid())
- scrollTo(idx.parent());
- scrollTo(idx);
-
+ QModelIndexList idxList = m->match(m->index(0, 0), DiveTripModel::DIVE_IDX, selected_dive, 2, Qt::MatchRecursive);
+ if (!idxList.isEmpty()) {
+ QModelIndex idx = idxList.first();
+ if (idx.parent().isValid())
+ scrollTo(idx.parent());
+ scrollTo(idx);
+ }
// now that everything is up to date, update the widgets
Q_EMIT currentDiveChanged(selected_dive);
dontEmitDiveChangedSignal = false;