Commit graph

288 commits

Author SHA1 Message Date
Robert C. Helling
e216f91ebc Prevent unintentionally running as root
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>
2016-03-26 20:08:08 -07:00
Dirk Hohndel
8f5a662441 QML UI: add the position source reported to the log
I've seen iPads without GPS report that they support satellite positioning.
Seems like a Qt bug to me.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-24 17:48:20 -07:00
Dirk Hohndel
f298802b99 QML UI: GPS location service - correctly calculate the delta
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-24 11:50:51 -07:00
Dirk Hohndel
b1037abdb7 QML UI: GPS location service - only show the fixes we store
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-24 11:50:46 -07:00
Dirk Hohndel
9a62685f0b Read GPS location service thresholds from settings
We used to faithfully save them, but not restore them at start.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-24 11:18:20 -07:00
Dirk Hohndel
aa4e3ba537 Give more information about the GPS location service
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>
2016-03-24 08:49:45 -07:00
Dirk Hohndel
509b664a29 Another small signed / unsigned warning fix
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>
2016-03-23 17:26:46 -07:00
Dirk Hohndel
788d65a527 Make code easier to read (and avoid warning)
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>
2016-03-23 17:26:46 -07:00
Dirk Hohndel
32e6cde548 Compare with the right git sha when deciding nothing has changed
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>
2016-03-23 13:25:10 -07:00
Dirk Hohndel
cc0f298980 When clearing dive file data, forget the saved git sha
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>
2016-03-23 12:09:18 -07:00
Dirk Hohndel
0cd0762807 Another attempt to clean up signed / unsigned in profile.c
This time we err on the side of signed variables most of the time.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-23 10:04:30 -07:00
Dirk Hohndel
22c94a3e65 Don't try to force depth to be unsigned
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>
2016-03-23 09:53:44 -07:00
Dirk Hohndel
0ae5f6faae Revert "Clean up signedness confusion in planner.c"
This reverts commit 59299f0ab3.

Doing this oversimplified "fix" actually breaks the planner.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-23 08:17:17 -07:00
Rick Walsh
0e5c8f101c Planner: add segment symbol to output table
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>
2016-03-19 10:45:37 +01:00
Robert C. Helling
e32ae20ca3 Fix loading images from URLs
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>
2016-03-16 07:46:28 -07:00
Robert C. Helling
8a59d78faa When handing off a picture to a worker thread, copy it first
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>
2016-03-16 07:46:28 -07:00
Dirk Hohndel
dca6eaa089 Use more informative error message in application log
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>
2016-03-13 18:22:54 -07:00
Linus Torvalds
fb5ce88b81 gas model: update to new coefficients, and simplify expressions
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>
2016-03-13 12:43:35 -07:00
Linus Torvalds
6b5e22a68e gas model: add proper He compressibility data and do a least-squares fit
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>
2016-03-13 12:43:30 -07:00
Linus Torvalds
fcf1898b0c gas-model: add R compressibility script
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>
2016-03-13 08:32:21 -07:00
Dirk Hohndel
d9c3fc9946 Revert "Clean up signedness confusion in gaspressures.h"
This reverts commit 7d1c2a142f.

Another one.
2016-03-10 07:40:15 -08:00
Dirk Hohndel
a678cba93a Revert "Clean up signedness confusion in profile.c"
This reverts commit 7f2ad93396.

Idiot maintainer to do cleanup like this right before a release
2016-03-10 07:37:18 -08:00
Dirk Hohndel
2d9c9c6a1c Silence warnings in linux.c
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 21:47:43 -08:00
Dirk Hohndel
0a585aad71 Silence warnings in qtserialbluetooth.cpp
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 21:47:41 -08:00
Dirk Hohndel
ae5c7a55be Clean up UEMIS downloader
Mostly signedness issues, but also removing useless code that didn't have
any effect.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 21:47:36 -08:00
Dirk Hohndel
349c27a96e Clean up signedness confusion in time.c
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 21:47:28 -08:00
Dirk Hohndel
c63f14eefc Remove unused function
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 21:47:25 -08:00
Dirk Hohndel
6920480463 Clean up signedness confusion in statistics.c
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 21:47:22 -08:00
Dirk Hohndel
7d1c2a142f Clean up signedness confusion in gaspressures.h
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 21:47:18 -08:00
Dirk Hohndel
7f2ad93396 Clean up signedness confusion in profile.c
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 21:47:15 -08:00
Dirk Hohndel
59299f0ab3 Clean up signedness confusion in planner.c
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 21:47:13 -08:00
Dirk Hohndel
b0283c2a99 Clean up signedness confusion in parse-xml.c
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 21:47:10 -08:00
Dirk Hohndel
1dab8800e5 Clean up signedness confusion in libdivecomputer.c
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 21:47:07 -08:00
Dirk Hohndel
ba34b168be Silence warning in file.c
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 21:47:04 -08:00
Dirk Hohndel
d2f7732d22 Clean up signedness confusion in divelist.c
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 21:47:02 -08:00
Dirk Hohndel
f2c40907c5 Clean up signedness confusion in dive.c
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>
2016-03-09 21:46:58 -08:00
Dirk Hohndel
ee6f60515c Silence warnings in cochran.c
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 21:46:29 -08:00
Tomaz Canabrava
a61ce696a4 Silence warnings in worldmap-save.c
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 11:44:57 -08:00
Tomaz Canabrava
5cebf43849 Silence warnings in save-xml.c
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 11:44:54 -08:00
Tomaz Canabrava
df55799a98 Silence warnings in save-html.c
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 11:44:51 -08:00
Tomaz Canabrava
91b096a310 Silence warnings in save-git.c
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 11:44:48 -08:00
Tomaz Canabrava
f469a55a46 Silence warnings in parse-xml.c
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 11:44:44 -08:00
Tomaz Canabrava
3d7a9a2095 Silence warnings in membuffer.c
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 11:44:41 -08:00
Tomaz Canabrava
77909ead62 Silence warnings in load-git.c
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 11:44:38 -08:00
Tomaz Canabrava
d3bbb85b86 Silence warnings in libdivecomputer.c
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 11:44:35 -08:00
Tomaz Canabrava
4fba319791 Silence warnings in git-access.c
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 11:44:30 -08:00
Tomaz Canabrava
2da2eb79bc Silence warnings in gaspressures.c
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 11:44:28 -08:00
Tomaz Canabrava
1048845650 Silence warnings in equipment.c
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 11:44:24 -08:00
Tomaz Canabrava
8109439261 Silence warnings in datatrack.c
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 11:44:20 -08:00
Tomaz Canabrava
ea1350e960 Silence warnings in cochram.c
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 11:44:17 -08:00