From f7e222718a6677912094c1994c1681bed5171b28 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 15 Aug 2021 10:05:59 -0700 Subject: desktop: avoid crash when changing dive logs If the last displayed dive had events, those DiveEventItems had slots connected that would update those icons if things changed. When closing the dive log and switching to a different one, those slots were still called and would then access freed memory (the event structure from that old dive that is long gone by then). This code explicitly deletes those DiveEventItems which also removes those signal slot connections. Fixes #3305 Sugested-by: Berthold Stoeger Signed-off-by: Dirk Hohndel --- profile-widget/profilewidget2.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'profile-widget') diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index 55a00a8e8..e296a8b9b 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -1078,7 +1078,11 @@ void ProfileWidget2::setEmptyState() hideAll(allPercentages); hideAll(handles); #endif - hideAll(eventItems); + // the events will have connected slots which can fire after + // the dive and its data have been deleted - so explictly delete + // the DiveEventItems + qDeleteAll(eventItems); + eventItems.clear(); hideAll(gases); } -- cgit v1.2.3-70-g09d2