We really have two different cases for merging dives:
(a) downloading a new dive from a dive computer, and merging it with an
existing dive that we had already created using a different dive
computer. This is the "try_to_merge()" case, called from
"process_dives()
(b) merging two different dives into one longer dive. This is the
"merge_two_dives()" case when you explicitly merge dives using the
divelist.
While a lot of the issues are the same, many details differ, and one of
the details is how dive numbering should be handled.
In particular, when you download from a dive computer and merge with an
existing dive, you want too take the *maximum* dive number, because the
dive computer notion of which dive it is may well not match what the
user dive number is.
On the other hand, when you explicitly merge in the dive list, you end
up renumbering not just the dive you are merging, but also all
subsequent dives, since you now have one fewer dives overall. So that
case already has to be handled by the caller.
Now, the simpler "download from dive computer" case was broken by commit
ce3a78efca ("Assign lower number to a merged dive instead of higher
one"). It fixed the numbering for the divelist case, but broke the
download case.
So this commit reverts commit ce3a78efca, and instead extends and
clarifies the dive renumbering that "merge_two_dives()" already did. It
now explicitly renumbers not just the following dives, but also
renumbers the merged dive itself, so now we can go back to the old "take
the bigger dive number" for the core merging, which fixes the download
case.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This was exactly backwards. If there already are changes we do NOT want to
reload - that would overwrite those changes for no good reason; after all, the
starting point was correct, so why throw the changes away?
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This way warning icons and tank change icons and other event markers are no
longer ridiculously tiny on retina screens. Oddly this doesn't appear to be
needed on Android, only on iOS.
Fixes#1033
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Some users try to run Subsurface as root for example to get around
permission problems with dive computer devices. This is a bad idea
since config files get touched as root and then cannot be read
as normal user anymore.
This patch allows running as root only with verbose option on. We can
assume if somebody manages to start subsurface as root this happens
from the command line.
For some reason, I couldn't get translation working at this stage.
Windows version is a stub.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
On iOS it seems that I get a fix every second. Even though the
QGeoPositionInfoSource is set up with an update interval of 5 minutes...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is in the Mac support file that wasn't compiled on Linux when I tried to
finish the cleanup.
Now this compiles without warnings on Mac and iOS as well.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The old expression wass correct because if dive_table.dives[j]->number is != 0,
then !dive_table.dives[j]->number is 0 and vice versa. But come on...
The new code seems much more natural and easier to read.
And of course the Apple compilers by default gave a warning because they
suspected a precedence bug with the old code.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The saved_git_id could be updated in is_git_repository() under certain
circumstances, so we need to make sure we compare to the sha that was
current as we entered this function. Since the pointer is just to a static
buffer we need to actually copy it (and then free it later).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Otherwise parse_file() thinks that this data has already been loaded and
doesn't re-read it, even though our internal data structures have been
erased - so a subsequent parse_file after clear_dive_file_data() that
opens the same git repository finishes successfully, but leaves the
dive_table empty which is of course incorrect.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Trying to clean up the signed vs. unsigned issues it becomes clear that
forcing depth to be unsigned causes way too many problems in the code.
So this commit goes the opposite direction; since we clearly aren't
limited INT_MAX vs UINT_MAX, simply make more of the depth related
variables signed.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add a symbol to each line of output table indicating whether a segment is an
ascent, descent, constant depth (user entered) or deco stop
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
This was broken when introducing loading images from the server. Now it first tries the
server and if that fails tries the actual URL.
Still, the image does not show up immediately, since the DivePictureModel is
unavailable to the image downloader to be told to update the images.
This needs to be fixed but in the mean time, the image is shown when the dive
is reselected (possibly on the next run) since it is then loaded from the cache.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
as otherwise we crash when the picture is freed before the
worker thread (to load from the net or to compute hashes)
is finished
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While on the desktop we show the error to the user, in Subsurface-mobile
it's only appended to the log; so in order to improve debuggability it
makes sense to show the full error there.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This updates the gas model to use the new virial coefficients from the R
script, and simplifies the expression a tiny bit by avoiding the
division by 1000 for the gas fractions, and replacing it with a multiply
by 0.001 at the end.
The virial coefficients for Oxygen and Nitrogen changed in the last
digits due to the use of a different tool for the least-square fitting.
That also accounts for the change in format (the coefficients are not
using scientific notation).
The coefficients for Helium changed noticeably more, since they are now
based on the new least-squares fit from the raw data.
But the actual end result does not change appreciably, the main
advantage is that now the numbers are easily reproducible.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Lubomir pointed to exactly where he got his data from, so I added that
raw Helium data to the R script, and let the least-squares fit just take
care of the interpolation between 273K and 323K.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
It annoyed me that we hand-waved a bit about how the virial factors were
actually computed in the gas-model.c file, so here's an actual R script
that computes them and plots the results.
You can run it with (for example):
R --vanilla < compressibility.r
and it will generate a Rplots.pdf of the plots, and the coefficients
will be shown on stdout.
The result actually differs in insignificant ways from the values that
Lubomir computed, which is likely just due to tools. I used R, Lubomir
seems to have used
http://polynomialregression.drque.net/online.php
but the actual curve is pretty much the same.
NOTE! R is not entirely happy about the non-linear fit of the Helium
curve: the fit is *so* precise that it failes the R relative-offset
convergence criterion. That is apparently generally a sign of
artificial data.
That is probably because Lubomir generated them from the linear mix of
two polynomial fits, rather than a linear mix of the original data. But
maybe the original data was artificial?
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This started out as cleaning up warnings - but it actually turned into a
matter of semantics and correctness. Which lead to changes in .h files
which will have a ton of ripple effects.
A lot more of this to come.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>