From 196bd7b7b247d8ac53574d4ab15ed25e66f92bc6 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 17 Dec 2020 23:45:48 +0100 Subject: profile: remove clearHandlers function (fixes crash) Recently (674c20227b2), the call to ProfileWidget::clearHandlers() was moved from PlannerWidgets::replanDive() to ProfileWidget2. This cause a crash, because the code assumes that the number of elements in the handles-vector the divepointplanner model is the same. Clearing the handles violates this assumption. It turns out that the clearHandlers() function is broken anyway: it clear the handles-vector, but not the gases-vector, which should likewise have the same number of elements. It appears that the clearHandlers() function is an artifact and it is mysterious how this has worked so far. Remove. Signed-off-by: Berthold Stoeger --- profile-widget/profilewidget2.cpp | 13 ------------- profile-widget/profilewidget2.h | 3 --- 2 files changed, 16 deletions(-) (limited to 'profile-widget') diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index 19819eae9..97cd6fe12 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -1318,17 +1318,6 @@ void ProfileWidget2::setProfileState() } #ifndef SUBSURFACE_MOBILE -void ProfileWidget2::clearHandlers() -{ - if (handles.count()) { - foreach (DiveHandler *handle, handles) { - scene()->removeItem(handle); - delete handle; - } - handles.clear(); - } -} - void ProfileWidget2::setToolTipVisibile(bool visible) { toolTipItem->setVisible(visible); @@ -1339,7 +1328,6 @@ void ProfileWidget2::setAddState() if (currentState == ADD) return; - clearHandlers(); setProfileState(); mouseFollowerHorizontal->setVisible(true); mouseFollowerVertical->setVisible(true); @@ -1373,7 +1361,6 @@ void ProfileWidget2::setPlanState() if (currentState == PLAN) return; - clearHandlers(); setProfileState(); mouseFollowerHorizontal->setVisible(true); mouseFollowerVertical->setVisible(true); diff --git a/profile-widget/profilewidget2.h b/profile-widget/profilewidget2.h index 272398095..4c6d66898 100644 --- a/profile-widget/profilewidget2.h +++ b/profile-widget/profilewidget2.h @@ -163,9 +163,6 @@ private: void createPPGas(PartialPressureGasItem *item, int verticalColumn, color_index_t color, color_index_t colorAlert, const double *thresholdSettingsMin, const double *thresholdSettingsMax); void clearPictures(); -#ifndef SUBSURFACE_MOBILE - void clearHandlers(); -#endif void plotPicturesInternal(const struct dive *d, bool synchronous); void addDivemodeSwitch(int seconds, int divemode); void addBookmark(int seconds); -- cgit v1.2.3-70-g09d2