From 67769235e78e7963a093bcf84e3b27ad1a0b8d6c Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 12 Aug 2021 08:26:08 +0200 Subject: 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 --- desktop-widgets/divelistview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'desktop-widgets') 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); -- cgit v1.2.3-70-g09d2