The Suunto FIT files end up creating a sample every second, but a lot of
those samples with no depth information, marked as "depth.mm" being negative.
That doesn't end up being a problem for subsurface, _except_ that it
really confuses our "dc_fixup_duration()" logic, and the dive duration
ends up being completely nonsensical (generally roughly by a factor of
five: every tenth sample has a depth, and we only count samples that
"begin or end under water" as being relevant for the dive duration, so
two out of the ten samples will count towards the dive time).
Saving the dive will then not save these invalid depths, so saving and
reloading the dive ends up fixing the dive duration calculation.
The fix is trivial - we just ignore samples with negative depth in
dc_fixup_duration().
The FIT file parser should probably be taught to not even bother sending
empty samples to subsurface, but that's a separate cleanup. This fixes
the actual bad behavior.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The (presumably) older label "Re-plan dive" in the Log menu was replaced with "Edit dive in planner",
but the documentation section "Modifying an existing dive plan" was not updated.
Signed-off-by: Tim D. Hammer <tdhammer@linux.com>
Fixes gcc complaining about
/build/subsurface-beta-202408210659/core/divecomputer.cpp: In function 'bool operator<(const event&, const event&)':
/build/subsurface-beta-202408210659/core/divecomputer.cpp:290:21: error: 'tie' is not a member of 'std'
290 | return std::tie(ev1.time.seconds, ev1.name) <
| ^~~
/build/subsurface-beta-202408210659/core/divecomputer.cpp:13:1: note: 'std::tie' is defined in header '<tuple>'; did you forget to '#include <tuple>'?
12 | #include <stdlib.h>
+++ |+#include <tuple>
13 |
/build/subsurface-beta-202408210659/core/divecomputer.cpp:291:21: error: 'tie' is not a member of 'std'
291 | std::tie(ev2.time.seconds, ev2.name);
| ^~~
/build/subsurface-beta-202408210659/core/divecomputer.cpp:291:21: note: 'std::tie' is defined in header '<tuple>'; did you forget to '#include <tuple>'?
Signed-off-by: Richard Fuchs <dfx@dfx.at>
This has become a bit of a catch-all overhaul of a large portion of the
planner - I started out wanting to improve the CCR mode, but then as I
started pulling all the other threads that needed addressing started to
come with it.
Improve how the gas selection is handled when planning dives in CCR
mode, by making the type (OC / CCR) of segments dependent on the gas use
type that was set for the selected gas.
Add a preference to allow the user to chose to use OC gases as diluent,
in a similar fashion to the original implementation.
Hide gases that cannot be used in the currently selected dive mode in
all drop downs.
Include usage type in gas names if this is needed.
Hide columns and disable elements in the 'Dive planner points' table if
they can they can not be edited in the curently selected dive mode.
Visually identify gases and usage types that are not appropriate for the
currently selected dive mode.
Move the 'Dive mode' selection to the top of the planner view, to
accommodate the fact that this is a property of the dive and not a
planner setting.
Show a warning instead of the dive plan if the plan contains gases that
are not usable in the selected dive mode.
Fix the data entry for the setpoint in the 'Dive planner points' table.
Fix problems with enabling / disabling planner settings when switching
between dive modes.
Refactor some names to make them more appropriate for their current
usage.
One point that is still open is to hide gas usage graphs in the planner
profile if the gas isn't used for OC, as there is no way to meaningfully
interpolate such usage.
Signed-off-by: Michael Keller <github@ike.ch>
In 1af00703b3 the constructor of
WSInfoModel was removed, not realizing that it contains a crucial
call to setHeaderDataStrings().
Fixes#4294
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Fixes gcc complaining about
/build/subsurface-beta-202408190452/core/event.cpp: In member function 'bool event::operator==(const event&) const':
/build/subsurface-beta-202408190452/core/event.cpp:64:21: error: 'tie' is not a member of 'std'
64 | return std::tie(time.seconds, type, flags, value, name) ==
| ^~~
/build/subsurface-beta-202408190452/core/event.cpp:6:1: note: 'std::tie' is defined in header '<tuple>'; did you forget to '#include <tuple>'?
5 | #include "subsurface-string.h"
+++ |+#include <tuple>
6 |
/build/subsurface-beta-202408190452/core/event.cpp:65:21: error: 'tie' is not a member of 'std'
65 | std::tie(b.time.seconds, b.type, b.flags, b.value, b.name);
| ^~~
/build/subsurface-beta-202408190452/core/event.cpp:65:21: note: 'std::tie' is defined in header '<tuple>'; did you forget to '#include <tuple>'?
Signed-off-by: Richard Fuchs <dfx@dfx.at>
If there were more than one redundant event in the 60 sec range,
the event would be deleted multiple time, leading to a crash.
Only mark for deletion once.
Moreover, don't consider events that were already marked for
deletion, because that would mean that redundant events all 59 secs
would lead to all events (but the first one) deleted.
Finally, optimize the loop by stopping once the 60 sec limit
is reached.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We check for the event, but then access it anyway even if it
doesn't exist. Should not happen, but let's be safe.
Found by Coverity.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Coverity correctly complains about an integer division followed
by an assignment to double. Hard to say if intended - but let's
do a floating point division instead.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is probably related to another commented out piece of code.
Disable until someone complains.
Fixes a (good) Coverity warning.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There was a memory leak in the error case of sqlite3_exec():
The error message was not freed (and also not displayed).
Display and free it. Is there a reasonable C++ version of this
library?
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The copy/pasting of dive-sites was fundamentally broken in at least two
ways:
1) The dive-site pointer in struct dive was simply overwritten, which
breaks internal consistency. Also, no dive-site changed signals where
sent.
2) The copied dive-site was stored as a pointer in a struct dive. Thus,
the user could copy a dive, then delete the dive-site and paste.
This would lead to a dangling pointer and ultimately crash the
application.
Fix this by storing the UUID of the dive-site, not a pointer.
To do that, don't store a copy of the dive, but collect all
the data in a `dive_paste_data` structure.
If the dive site has been deleted on paste, do nothing.
Send the appropriate signals on pasting.
The mobile version had an additional bug: It kept a pointer to the
dive to be copied, which might become stale by undo.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
D7 232 Bar tank added in line 342.
D7 232 Bar are common in Europe, not just D7 300 Bar.
Signed-off-by: gregbenson314 <99766165+gregbenson314@users.noreply.github.com>
Also, turn it to use std::string instead of writing into a
global(!) buffer. This was not reentrant.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Feels natural in a C++ code base.
The commit is somewhat complex, because it also changes the
return type to volume_t. The units system really needs some
work. :(
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Feels natural in a C++ code base.
In analogy to other tables, this creates a struct that derives
from std::vector<>. This is generally frowned upon, but it works
and is the pragmatic thing for now. If someone wants to "fix" that,
they may just do it.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This one-liner wasn't really doing anything and there was only
one user of the return value.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The important point is that this now takes a reference that
avoid string copying. The old code used C-strings and therefore
copy-semantics were OK.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
These were declared in dive.h, which makes no sense.
This should have been chnaged a long time ago.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Feels natural in a C++ code base.
This removes a nullptr-check so some care has to be taken.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>