summaryrefslogtreecommitdiffstats
path: root/qt-ui/divelistview.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-13 13:59:02 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-13 13:59:02 +0900
commit25e432e1d16efaaf0db3112222e7e3716c8e6304 (patch)
tree4c0936a8dad478cbe0d1df984a2e835dc14b6430 /qt-ui/divelistview.cpp
parent17b5618c3984cbeef3b14a222f259e4f83fe9f28 (diff)
downloadsubsurface-25e432e1d16efaaf0db3112222e7e3716c8e6304.tar.gz
When selection gets confused, don't try to select non-existing dive
While the argument could be made that this is just a symptom of Subsurface getting very confused about the selection (which it still gets at times - most likely we are calling select_dive() instead of selectDive() (or the corresponding deselect functions) in places where we shouldn't), but either way, we should not crash. Fixes #220 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/divelistview.cpp')
-rw-r--r--qt-ui/divelistview.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index 0fdd6fc91..f33d709e9 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -119,6 +119,8 @@ void DiveListView::unselectDives()
void DiveListView::selectDive(struct dive *dive, bool scrollto, bool toggle)
{
+ if (dive == NULL)
+ return;
QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel*>(model());
QModelIndexList match = m->match(m->index(0,0), DiveTripModel::NR, dive->number, 1, Qt::MatchRecursive);
QItemSelectionModel::SelectionFlags flags;
@@ -227,7 +229,7 @@ void DiveListView::reload(DiveTripModel::Layout layout, bool forceSort)
return;
sortByColumn(sortColumn, currentOrder);
- if (amount_selected && selected_dive >= 0) {
+ if (amount_selected && current_dive != NULL) {
selectDive(current_dive, true);
} else {
QModelIndex firstDiveOrTrip = m->index(0,0);