From 9bfc6d2520b83b8151a84e23cbab082ab460532e Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 8 Jan 2021 23:55:20 +0100 Subject: profile: use a parameter to determine planner state The in_planner() function is incompatible with a reentrant profile, since it accesses a global variable. In create_plot_info_new() it is essentially redundant, because there is a planner_ds (ds = deco_state) parameter that is used only when in the planner. Therefore use that as the in_planner indicator: when non-null, the profile is showing a planned dive. Signed-off-by: Berthold Stoeger --- profile-widget/profilewidget2.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'profile-widget') diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index 546a618d8..5e32f39a8 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -598,6 +598,7 @@ void ProfileWidget2::plotDive(const struct dive *d, bool force, bool doClearPict ccrsensor3GasItem->setVisible(sensorflag && (currentdc->no_o2sensors > 2)); ocpo2GasItem->setVisible((currentdc->divemode == PSCR) && prefs.show_scr_ocpo2); + /* This struct holds all the data that's about to be plotted. * I'm not sure this is the best approach ( but since we are * interpolating some points of the Dive, maybe it is... ) @@ -608,7 +609,9 @@ void ProfileWidget2::plotDive(const struct dive *d, bool force, bool doClearPict // create_plot_info_new() automatically frees old plot data #ifndef SUBSURFACE_MOBILE - create_plot_info_new(&displayed_dive, currentdc, &plotInfo, !shouldCalculateMaxDepth, &DivePlannerPointsModel::instance()->final_deco_state); + // A non-null planner_ds signals to create_plot_info_new that the dive is currently planned. + struct deco_state *planner_ds = currentState == PLAN ? &DivePlannerPointsModel::instance()->final_deco_state : nullptr; + create_plot_info_new(&displayed_dive, currentdc, &plotInfo, !shouldCalculateMaxDepth, planner_ds); #else create_plot_info_new(&displayed_dive, currentdc, &plotInfo, !shouldCalculateMaxDepth, nullptr); #endif -- cgit v1.2.3-70-g09d2