mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
17b5618c39
commit
25e432e1d1
1 changed files with 3 additions and 1 deletions
|
@ -119,6 +119,8 @@ void DiveListView::unselectDives()
|
||||||
|
|
||||||
void DiveListView::selectDive(struct dive *dive, bool scrollto, bool toggle)
|
void DiveListView::selectDive(struct dive *dive, bool scrollto, bool toggle)
|
||||||
{
|
{
|
||||||
|
if (dive == NULL)
|
||||||
|
return;
|
||||||
QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel*>(model());
|
QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel*>(model());
|
||||||
QModelIndexList match = m->match(m->index(0,0), DiveTripModel::NR, dive->number, 1, Qt::MatchRecursive);
|
QModelIndexList match = m->match(m->index(0,0), DiveTripModel::NR, dive->number, 1, Qt::MatchRecursive);
|
||||||
QItemSelectionModel::SelectionFlags flags;
|
QItemSelectionModel::SelectionFlags flags;
|
||||||
|
@ -227,7 +229,7 @@ void DiveListView::reload(DiveTripModel::Layout layout, bool forceSort)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sortByColumn(sortColumn, currentOrder);
|
sortByColumn(sortColumn, currentOrder);
|
||||||
if (amount_selected && selected_dive >= 0) {
|
if (amount_selected && current_dive != NULL) {
|
||||||
selectDive(current_dive, true);
|
selectDive(current_dive, true);
|
||||||
} else {
|
} else {
|
||||||
QModelIndex firstDiveOrTrip = m->index(0,0);
|
QModelIndex firstDiveOrTrip = m->index(0,0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue