From ada4632ff1667a1070d0a5680341b5db0b52404b Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 3 Apr 2022 11:23:51 +0200 Subject: [PATCH] profile: remove last dc_number access from profile code dc_number is a global variable indicating the currently displayed dive on desktop. It makes no sense on mobile, since multiple profiles can be active at the same time. Therefore, the profile code should not access this global, but use the dc number that is passed in. This removes the last access. Signed-off-by: Berthold Stoeger --- profile-widget/profilescene.cpp | 2 +- profile-widget/tankitem.cpp | 8 ++------ profile-widget/tankitem.h | 3 ++- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/profile-widget/profilescene.cpp b/profile-widget/profilescene.cpp index e8063d910..04a431380 100644 --- a/profile-widget/profilescene.cpp +++ b/profile-widget/profilescene.cpp @@ -514,7 +514,7 @@ void ProfileScene::plotDive(const struct dive *dIn, int dcIn, DivePlannerPointsM animatedAxes.push_back(timeAxis); cylinderPressureAxis->setBounds(plotInfo.minpressure, plotInfo.maxpressure); - tankItem->setData(d, firstSecond, lastSecond); + tankItem->setData(d, currentdc, firstSecond, lastSecond); if (ppGraphsEnabled(currentdc, simplified)) { double max = prefs.pp_graphs.phe ? max_gas(plotInfo, &gas_pressures::he) : -1; diff --git a/profile-widget/tankitem.cpp b/profile-widget/tankitem.cpp index 8715c963e..3079c10dd 100644 --- a/profile-widget/tankitem.cpp +++ b/profile-widget/tankitem.cpp @@ -62,13 +62,13 @@ void TankItem::createBar(int startTime, int stopTime, struct gasmix gas) label->setZValue(101); } -void TankItem::setData(const struct dive *d, int plotStartTime, int plotEndTime) +void TankItem::setData(const struct dive *d, const struct divecomputer *dc, int plotStartTime, int plotEndTime) { // remove the old rectangles qDeleteAll(rects); rects.clear(); - if (!d) + if (!d || !dc) return; // We don't have enougth data to calculate things, quit. @@ -79,10 +79,6 @@ void TankItem::setData(const struct dive *d, int plotStartTime, int plotEndTime) if (d->cylinders.nr <= 0) return; - // get the information directly from the displayed dive - // (get_dive_dc() always returns a valid dive computer) - const struct divecomputer *dc = get_dive_dc_const(d, dc_number); - // start with the first gasmix and at the start of the dive int cyl = explicit_first_cylinder(d, dc); struct gasmix gasmix = get_cylinder(d, cyl)->gasmix; diff --git a/profile-widget/tankitem.h b/profile-widget/tankitem.h index 895c313f7..f61615fdf 100644 --- a/profile-widget/tankitem.h +++ b/profile-widget/tankitem.h @@ -8,13 +8,14 @@ #include struct dive; +struct divecomputer; class DiveCartesianAxis; class TankItem : public QGraphicsRectItem { public: explicit TankItem(const DiveCartesianAxis &axis, double dpr); - void setData(const struct dive *d, int plotStartTime, int plotEndTime); + void setData(const struct dive *d, const struct divecomputer *dc, int plotStartTime, int plotEndTime); double height() const; private: