summaryrefslogtreecommitdiffstats
path: root/profile-widget/diveprofileitem.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-09-10 20:40:25 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-09-10 14:23:59 -0700
commit6e4a2538968d945d471489270136c4891b47b270 (patch)
treedbe442feff12bdb1414712e926eac593deb8a1d9 /profile-widget/diveprofileitem.cpp
parentc75f53a7a802fd9745376b837f6c307ba82d5b7b (diff)
downloadsubsurface-6e4a2538968d945d471489270136c4891b47b270.tar.gz
Profile: fix SAC calculation for air dives
Commit f5b11daffd6f240268ce78d72c64be43670988ea changed gasmix arguments and return values to be passed by value instead of using pointers. Notably, get_gasmix() is fed a default-value and returns a new value. In the old code, NULL was passed in in a first loop iteration and non-NULL was always returned in the first iteration. Thus, an equality comparison of passed-in an returned gasmix would always fail in the first loop iteration. The new code passed in air as default. Now if air was also returned, then the matching gases were not calculated in calculate_sac(). To revert to the old behavior, pass in an invalid gasmix. Moreover, give names to the invalid and air gasmixes. Reported-by: tormento <turment@gmail.com> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget/diveprofileitem.cpp')
-rw-r--r--profile-widget/diveprofileitem.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/profile-widget/diveprofileitem.cpp b/profile-widget/diveprofileitem.cpp
index ef47b0d59..733f7e68f 100644
--- a/profile-widget/diveprofileitem.cpp
+++ b/profile-widget/diveprofileitem.cpp
@@ -410,7 +410,7 @@ void DivePercentageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
for (int i = 1, modelDataCount = dataModel->rowCount(); i < modelDataCount; i++) {
if (i < poly.count()) {
double value = dataModel->index(i, vDataColumn).data().toDouble();
- struct gasmix gasmix = { 0 };
+ struct gasmix gasmix = gasmix_air;
const struct event *ev = NULL;
int sec = dataModel->index(i, DivePlotDataModel::TIME).data().toInt();
gasmix = get_gasmix(&displayed_dive, displayed_dc, sec, &ev, gasmix);