From 81f35c1ecfa43f1840656ba22b1e55f1fa2fd970 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Sun, 10 Sep 2023 19:24:57 +0200 Subject: [PATCH] Properly handle the planner state This does two independent things: It sets the planner state early enough so the appropriate default profile for the planner is created (without safety stop). Upon cancelling the planner, it resets the profile widget to profile more (rather than planner) as otherwise upon the next change into the planner the planner model is not properly initialized. Signed-off-by: Robert C. Helling --- desktop-widgets/diveplanner.cpp | 1 + desktop-widgets/mainwindow.cpp | 2 +- profile-widget/profilewidget2.cpp | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp index f545fecd0..1e1df3a4d 100644 --- a/desktop-widgets/diveplanner.cpp +++ b/desktop-widgets/diveplanner.cpp @@ -568,6 +568,7 @@ divemode_t PlannerWidgets::getRebreatherMode() const void PlannerWidgets::preparePlanDive(const dive *currentDive) { + DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN); // create a simple starting dive, using the first gas from the just copied cylinders DivePlannerPointsModel::instance()->createSimpleDive(planned_dive.get()); diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 19f3e46f2..9c03f2e5b 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -581,7 +581,7 @@ void MainWindow::enableShortcuts() void MainWindow::showProfile() { enableShortcuts(); - profile->plotCurrentDive(); + profile->plotDive(current_dive, profile->dc); setApplicationState(ApplicationState::Default); } diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index d362c462d..22ac062ca 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -393,6 +393,7 @@ static void hideAll(const T &container) void ProfileWidget2::clear() { + currentState = INIT; #ifndef SUBSURFACE_MOBILE clearPictures(); #endif