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>
Feel natural in a C++ code base.
Remove the second parameter, because all callers where passing
`true` anyway.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Feels natural in a C++ code base.
Change the function to return a weight_t. Sadly, use of the
units.h types is very inconsistent and many parts of the code
use int or double instead. So let's try to make this consistent.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>