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>
Feels natural in a C++ code base.
Moreover, remove the fulltext-unregistration, as this is a
layering violation.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
It is unclear why this was declared in divelist.h.
Moreover, rename it to get_maximal_gas() to better reflect
what it does.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
These functions have to access other dives in the list to
calculate CNS, etc, so let's call them from there.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
These functions have to access other dives in the list to
calculate CNS, etc, so let's call them from there.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This accesses the global dive_table, so make this explicit.
Since force_fixup_dive() and default_dive() use fixup_dive(),
also move them to struct dive_table.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Before, a non-owning pointer was passed and the dive moved
away from the dive. Instead, let the caller decide if they
still want to keep a copy of the dive, or give up ownership:
In MainWindow and QMLManager new dives are generated, so
one might just as well give up ownership. In contrast,
the planner works on a copy (originally the infamous
"displayed_dive") and now moves the data manually.
This commit also removes duplicate code, by moving the
"create default dive" code from MainWindow and QMLManager
to struct dive.
Finally, determination of the "time zone offset" is not done
in POSIX, since we want to avoid calls form the core into
Qt.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This implicitly accessed the global divelog. Most of the users were
in the test/ folder anyway. Replace by explicit accesses to the
global divelog.dives.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
These functions accessed the global divelog make this explicit.
I'm still not happy about the situation, because these functions
access global state, such as the selection. I think these
should be moved up the call-chain.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This function implicitely accessed the global divelog. To make
that explicit make it a member of dive_table, such that the
caller must access it via the global variable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This one is for symmetry with unregister_dive(). However, it
makes me unhappy, because it modifies global state, namely the
selection machinery and the fulltext. I think these should be
moved up in the call chain.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This function implicitely accessed the global divelog. To make
that explicit make it a member of dive_table, such that the
caller must access it via the global variable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>