aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-08-12 08:26:08 +0200
committerGravatar bstoeger <32835590+bstoeger@users.noreply.github.com>2021-08-12 20:57:26 +0200
commit67769235e78e7963a093bcf84e3b27ad1a0b8d6c (patch)
tree5f62fd70d36e5cd560d4671b24ad41554eece99b /desktop-widgets
parentf308a6b57be0a79bef93d8b088dca1c2baf9f105 (diff)
downloadsubsurface-67769235e78e7963a093bcf84e3b27ad1a0b8d6c.tar.gz
desktop: fix crash when right-clicking of trip headers
Commit e42fc1a1e9a13c77d3474dbcb26b68b8772b8c6d introduced a crash condition. Apparently the code attempts to test whether the clicked-on item is a top-level dive. The "Collapse others" menu item should not be shown in that case. It does this by testing "d->divetrip". However, "d" might quite logically be null if clicking on an unexpanded trip header. Therefore, check explicitly for the trip header case (which should show the menu item) and for good measure prevent the nullpointer access (that should be caught by testing for trip, but who knows). Fixes #3301. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/divelistview.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp
index a50c81756..cbd238927 100644
--- a/desktop-widgets/divelistview.cpp
+++ b/desktop-widgets/divelistview.cpp
@@ -779,7 +779,7 @@ void DiveListView::contextMenuEvent(QContextMenuEvent *event)
popup.addAction(tr("Collapse all"), this, &QTreeView::collapseAll);
// verify if there`s a need for collapse others
- if (expanded_nodes > 1 && d->divetrip)
+ if (expanded_nodes > 1 && (trip || (d && d->divetrip)))
collapseAction = popup.addAction(tr("Collapse others"), this, &QTreeView::collapseAll);