The pressure data was directly accessed in fill_missing_tank_pressures().
Use the already existing functions so that the structures can be adapted
easily.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The only apparent reason that this was a macro is that it automatically
increased the "index" and "entry" counts. But incrementing these explicitly
seems reasonable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Continue with replacing pointers to struct plot_data entries
by indexes. Thus the pressure data can be kept in its own
array and can by dynamically sized.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The ProfileWidget2::getEntryFromPos() function was only used
by code that was commented out. Thus comment it out as well.
Moreover, turn the accompanying FIXME comments into TODO comments
to avoid a new LGTML alert.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The goal here is to make it possible to detach the pressure related
data from the plot_info structure. Thus, the pressure related data
can be allocated independently depending on the number of cylinders
per dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To make the pressure data dynamic (size of the arrays depending
on the cylinders in the dive), it has to be separated from the
standard plot_data structure. To enable this, use indexes instead
of pointers to plot_data elements. This commit converts
the RulerItem2 to use an index.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of using a sub-array, use a std::vector<>. This is
a necessary step in removing the MAX_CYLINDERS restriction.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Dynamically allocate cylinder arrays in C code. This is a tiny
step in removing the MAX_CYLINDERS limitation.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When keeping track of cylinder related data, the code was using
static arrays of MAX_CYLINDERS length. If we want to use dynamically
sized cylinder arrays, these have to be dynamically allocated.
In C++ code, this is trivial: simply replace the C-style arrays
by std::vector<>. Don't use QVector, as no reference counting or
COW semantics are needed here. These are purely local and unshared
arrays.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
get_gas_used() returns the volume of used gases. Currently,
an array with MAX_CYLINDERS is passed in. If we want to make the
number of cylinders dynamic, the function must use an arbitrarilly
sized array.
Therefore, return a dynamically allocated array and free it
in the caller.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
libssh2 depends on openssl, therefore it is important that openssl is
build before libssh2.
The old get-deps would cause errors in 2 situations:
1) In a clean build, make of libssh2 would fail
2) In a normal build, where openssl changed version, make of libssh2 would
depend on old build.
Signed-off-by: Jan Iversen <jan@casacondor.com>
This is even harder because setActiveTrip is called from an action slot from
QML. If the C++ code called from that slot causes the object to which this slot
belongs to be destroyed, we get very strange crashes. The only workaround I
could come up with was to update the filter asynchronously.
This all seems very ugly and fragile.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When we change the filter string, we need to make sure that the collapsed model is
also aware of the change.
Similarly, instead of just calling resetFilter and directly changing the core
data structures, we need to set the filter to the empty string which ensures
that all three models get notified and the view updates correctly.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This shouldn't be necessary every time we replace the sort model,
but it can't hurt, either (famous last words?).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This one significantly reduces the number of dives that are handed to the
ListView in QML. For every trip that isn't expanded (only zero or one trips are
expanded at any time, so almost all the others are collapsed), send only first
dive to the View to allow creation of the section. Hide the rest so we don't
have all these invisible, zero height entries for the vertical dive list.
A big part of this commit is moving a few functions from the DiveListSortModel
to the CollapsedDiveListSortModel. Those are the ones that are needed for the
trip header.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The previous code assumes that both the vertical dive list and the list of dive
details which allows the horizontal swiping from dive to dive are based on the
same model.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Memory is cheap these days. Still, this was wasteful. On a 64 bit machine we
went from 1620 to 1592 bytes.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Running Subsurface-mobile on iOS, the notification texts are sometimes very
hard to read, and in some situations the busy indicator isn't showing up at
all.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While the error that caused this to happen should be fixed, we should at least
let the user know if things failed catastrophically and we can't figure out how
to save their data.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If there is a local cache, we at least once successfully accessed the cloud, so
this is a valid cloud based git tree.
Without this change we run into a subtle bug: after a fresh install, or when
switching users, when the cloud data is accessed the very first time, we don't
remember that this was indeed loaded from the cloud. So if we then download
from a dive computer or make any other changes to the dive log, we cannot save
those dives to cloud storage - but we fail silently doing so. Which to the user
would look that inexplicable data loss.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The NOTICE and copyright are freeform. The new description key is required for
iOS 13, but of course the redundant old key is still required for older
builds...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When trying to debug on device Xcode really wants a debug build (which is
nearly unusably slow, but that's a different issue).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Those aren't allowed on iOS and adding these two flags removes some confusing
warnings that look like errors in the build log.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The ProfileWidget2::recalcCeiling() function is used in one place,
namely when an undo-command changes the mode. It recalculates
decompression data and repaints the ceilings and thus avoids a
full profile-redraw.
This is smart, but it becomes problematic when the dive is changed
and the ceiling is recalculated before the profile is redrawn.
The DivePlotDataModel then still has data from the previous dive
but cylinders of the new dive are accessed.
This kind of situation may arise if multiple dive fields are
updated, as for example when replanning a dive.
Currently, this only causes a temporary mis-calculation. When
removing MAX_CYLINDERS this will lead to crashes.
One might attempt to fix the whole data-dependency mess. This
commit goes the cheap route and simply redraws the profile when
the mode is changed. Yes, it is in a way ineffective, but we
do worse things. The ProfileWidget2::recalcCeiling() thus becomes
unused and is removed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When displaying segment or stop times in the planner notes, we always
round to the next full minute. This can mean for example that we
round down more often than rounding up with the result that the sum
of the segment times does not match the total runtime and can for example
lead to stops that are shown with 0min duration.
With this patch, we increase the reference time of the last display only
by the duration time actually shown. This way, the rounding errors don't
accumulate but having rounded down previously makes rounding up the next
time more propable.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
If the dive list is connected to the model while the model is updated
with the downloaded dives, sometimes the UI hangs completely.
Disconnecting the model and then reconnecting it does add a fairly
noticeable delay on longer dive lists, so there are tradeoffs here.
Of course the obvious solution is to make reconnecting the model
faster...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This helps tremendously when tracking down some problems. We should
never use console.log.
In the process this also updates a couple of the messages to be clearer.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When computing the best mix for a target depth, for helium, one
can either require that the partial pressure of N2 is the same
as at the target depth or the partial pressure of N2 plus O2.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
We should call this function with two well defined dive_or_trip structures
which means that exactly one of the two values is set in each argument. But
in order to not have bugs elsewhere leed to crashes here, be more tolerant
of malformed argumnts.
Fixes CID 350100
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We test for d being NULL so that's clearly an option we worried about, yet
we already called get_dive_site_for_dive(d) which dereferences d.
Found by Coverity. Fixes CID 350118
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This should never happen based on the logic in the callers, but just
to be on the safe side.
Should fix CID 350128
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When clicking "done" on the dive site edit screen, the diveSite
member variable was reset to nullptr in acceptChanges() at the
beginning of the function. This prevented posting an undo-command
as a consequence of the active widget losing focus.
Reset the diveSite variable after exiting dive-site mode, which
causes the active widget to lose focus.
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>