diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-05-01 11:30:50 +0200 |
---|---|---|
committer | Robert C. Helling <helling@atdotde.de> | 2020-05-01 21:44:50 +0200 |
commit | f4b948e80d15f986887e647ff4e20de9e0d6453d (patch) | |
tree | 17f6e1159978a829877d237b1400b65beb0b0429 /profile-widget | |
parent | 9c70261c0e294d46d62d99725a1ae9ddc01eb1cf (diff) | |
download | subsurface-f4b948e80d15f986887e647ff4e20de9e0d6453d.tar.gz |
profile: properly update lastgasmix when populating events
When populating the events of a profile, a pointer to the current
gasmix was passed around to properly calculate isobaric_counterdiffusion.
The DiveEventItem::setupToolTipString() function updated this gasmix
when processing gas change events.
I inadvertently broke the code when replacing gasmix-pointers by
values. We could of course simply revert this part of the commit.
However, the data flow was horrible anyway: for example is supposed
that the setup functions were called in the correct order (i.e.
DiveEventItem::setupToolTipString() is called after all other
functions using the gasmix). Not exactly easy to follow.
Therefore, keep passing around the gasmix as value to make it clear
that the functions don't modify it. Keep the gasmix up-to-date at
the caller's site in ProfileWidget2::plotDive().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget')
-rw-r--r-- | profile-widget/diveeventitem.cpp | 1 | ||||
-rw-r--r-- | profile-widget/profilewidget2.cpp | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/profile-widget/diveeventitem.cpp b/profile-widget/diveeventitem.cpp index ecd64aba0..dcb4d8af0 100644 --- a/profile-widget/diveeventitem.cpp +++ b/profile-widget/diveeventitem.cpp @@ -195,7 +195,6 @@ void DiveEventItem::setupToolTipString(struct gasmix lastgasmix) name += QString::fromUtf8(mb.buffer, mb.len); free_buffer(&mb); } - lastgasmix = mix; } else if (same_string(internalEvent->name, "modechange")) { name += QString(": %1").arg(gettextFromC::tr(divemode_text_ui[internalEvent->value])); } else if (value) { diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index cd28a87bc..365f4758d 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -802,6 +802,8 @@ void ProfileWidget2::plotDive(const struct dive *d, bool force, bool doClearPict item->setZValue(2); scene()->addItem(item); eventItems.push_back(item); + if (event_is_gaschange(event)) + lastgasmix = get_gasmix_from_event(&displayed_dive, event); event = event->next; } |