From e0e21cab3d2cb9d8453334eb8f04b87ea0a785b8 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 30 Oct 2022 08:58:23 +0100 Subject: [PATCH] profile: reverse plotting and showing of profile When switching from "empty mode" (i.e. the subsurface logo is shown, because no dive is selected), the profile is first shown by switching to the appropriate tab and then plotted. However, the showing might lead to a resize event and then to a crash with owing to stale dive data. Therefore, reverse that. Note that I never could reproduce that. Reported-by: Robert C. Helling Signed-off-by: Berthold Stoeger --- desktop-widgets/profilewidget.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/desktop-widgets/profilewidget.cpp b/desktop-widgets/profilewidget.cpp index 9582d1bba..15e98420a 100644 --- a/desktop-widgets/profilewidget.cpp +++ b/desktop-widgets/profilewidget.cpp @@ -155,7 +155,6 @@ void ProfileWidget::setEnabledToolbar(bool enabled) void ProfileWidget::setDive(const struct dive *d) { - // If the user was currently editing a dive, exit edit mode. stack->setCurrentIndex(1); // show profile bool freeDiveMode = d->dc.divemode == FREEDIVE; @@ -198,13 +197,13 @@ void ProfileWidget::plotCurrentDive() setEnabledToolbar(current_dive != nullptr); if (editedDive) { - setDive(originalDive); view->plotDive(editedDive.get(), editedDc); + setDive(editedDive.get()); } else if (current_dive) { - setDive(current_dive); view->setProfileState(current_dive, dc_number); view->resetZoom(); // when switching dive, reset the zoomLevel view->plotDive(current_dive, dc_number); + setDive(current_dive); } else { view->clear(); stack->setCurrentIndex(0); @@ -235,8 +234,8 @@ void ProfileWidget::divesChanged(const QVector &dives, DiveField field) void ProfileWidget::setPlanState(const struct dive *d, int dc) { exitEditMode(); - setDive(d); view->setPlanState(d, dc); + setDive(d); } void ProfileWidget::unsetProfHR()