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: