Commit graph

2126 commits

Author SHA1 Message Date
Berthold Stoeger
8ce7c4664a cleanup: move DECOTIMESTEP from dive.h to planner.h
Long-term project: reduce the size of dive.h

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01 09:42:31 -07:00
Berthold Stoeger
44132e44a9 cleanup: make enumerate_devices of external linkage
For consistency: declare enumerate_dives as extern, since we do that
for all other C-functions.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01 08:53:45 -07:00
Berthold Stoeger
c8334ad11b cleanup: make analyze_plot_info local to profile.c
No external caller of this function exists. Moreover, turn the return
type to void, as it only returned the passed-in plot_info and no
caller used that.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01 08:53:45 -07:00
Berthold Stoeger
21e2488d2d cleanup: const-ify a few functions in planner.c
It make debugging much easier if the function signature tells you
that a parameter is not altered.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01 08:53:45 -07:00
Berthold Stoeger
d787e8812c profile: for maxtime calculation include the sample after the last event
When plotting profiles with surface segments, there were strange
artifacts. As we found out with Robert, these were due to the fact
that the calculated maxtime was set to the last event which is just one
second inside the surface segment. This terribly confused the profile
code. For example, it didn't properly allocate samples for the surface
segment.

Thus, when calculating maxtime, consider the last sample beyond the
last event.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01 12:36:28 +02:00
Berthold Stoeger
8bc4233add profile: return air for one-past last cylinder
This is the code for "surface air".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01 12:36:28 +02:00
Berthold Stoeger
ffc3e598fa core: create fake cylinder at end of cylinder table (hack!)
When we had fixed-sized cylinder arrays, the planner used the last
empty cylinder for "surface air". This was not recognized by the UI
as a separate cylinder, because "empty cylinder" was the sentinel for
the end of the table. The conversion to dynamically sized cylinder
tables broke this code: everytime the surface segment is changed,
a new dummy cylinder is added, which is visible in the UI.

As a very temporary stop-gap fix, emulate the old code by creating
a cylinder and then setting the end-of-table to before that cylinder.
This means that we have to loosen the out-of-bound checks.

That's all very scary and should be removed as soon as possible.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01 12:36:28 +02:00
Berthold Stoeger
b949bad026 core: always keep an empty cylinder at the end of the cylinder array
This will be temporarilly used by the planner to mark consumption of
air at the surface. Do this by creating a new function add_cylinder,
which replaces add_to_cylinder_table() and takes care of always adding
a dummy cylinder at the end of the table. Make the original
add_to_cylinder_table() local, so that it cannot be accessed anymore.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01 12:36:28 +02:00
Berthold Stoeger
5ba7c68433 cleanup: remove unused function get_divepoint_gas_string()
The last user was removed way back in commit
9fbd11744f.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-27 22:48:15 +03:00
Berthold Stoeger
f43b3f56b2 cleanup: remove Command::inCommand()
This was used by the divelist to check wether a selection change is
programmatical or user-initiated. However, since there is only one
entry point for programmatical selection changes, this is not needed
anymore. Remove it - this removes an inter-module dependency.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-26 13:54:59 -07:00
Dirk Hohndel
0fe02af0e8 build-system/android: remove libusb at QTest
We no longer use libusb to access USB devices on Android, therefore
there's no point including libusb in our build. Also, we have never even
attempted to run the tests on Android, so let's not even pretend to
support building them.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-25 13:18:41 -07:00
Berthold Stoeger
d8fabd241c cleanup: move clearing of event names to clear_dive_file_data()
Move this to the core so that desktop and mobile don't have
to call this explicitly. Matter of fact, mobile didn't call
this. It is unclear, whether that was even used on mobile,
though.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-24 10:40:12 -07:00
Berthold Stoeger
17526ded58 cleanup: move clearing of device nodes to clear_dive_file_data()
It makes no sense to keep the device nodes if all the other data
is cleared. Let's do this automatically and not explicitly.
This ensures that the function is also called on mobile.
Currently it was only called on desktop.

Weirdly, the parser-tests were expecting that the device nodes
were not reset by clear_dive_file_data() and therefore divecomputers
were accumulating in the test results. Thus, the additional
computers had to be removed from the expected test results.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-24 10:40:12 -07:00
Berthold Stoeger
52f93ea326 cleanup: whitespace fix
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-24 10:40:12 -07:00
Berthold Stoeger
9386eb2a0b cleanup: move get_dc_nickname from qthelper.cpp to divecomputer.cpp
1) qthelper is already huge.
2) set_dc_nickname et al. is already there.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-24 10:40:12 -07:00
Berthold Stoeger
3d4698c0a1 filter: add a week to maximum default date time
The filter sets the maximum date to now. This is so confusing when
you manually add a dive and it isn't shown, because it is slightly
in the future. Add seven days, that should help.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-24 10:05:27 -07:00
Berthold Stoeger
89784a176e filter: implement filtering for divemode
This only checks the first divecomputer as the semantics for
multiple dive computers with different dive modes are not
clear. Should we check them all?

The implementation is a bit hackish: the indexes [0...n] of the
combobox are mapped onto [-1...n-1], where -1 means don't filter
and n-1 is the last valid dive mode.

Implements #2329

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-24 10:05:27 -07:00
Berthold Stoeger
4aebcdc021 core: return -1 from explicit_first_cylinder() if dive has no cylinders
Arguably, returning 0 for a dive with no cylinders is wrong, since the
0 is a valid cylinder id, however that cylinder doesn't exist. Instead,
return -1. All callers of explicit_first_cylinder() return early anyway
for dives with no cylinders.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-20 12:59:06 -07:00
Berthold Stoeger
d81df0dd19 profile: avoid invalid accesses in setup_gas_sensor_pressure
Since we removed MAX_CYLINDERS, we have the possibility of dives
with no cylinders. In such a case, setup_gas_sensor_pressure()
would do invalid read- and write-accesses. Therefore, return
early in such a case.

Reported-by: Chirana Gheorghita Eugeniu Theodor <office@adaptcom.ro>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-20 12:59:06 -07:00
Dirk Hohndel
ad66297cfd desktop: remove user survey
We have never made good use of the results. Let's just remove it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-19 14:27:54 -07:00
Dirk Hohndel
12bafa4e41 core: debug cert calls
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-18 09:00:21 -07:00
Dirk Hohndel
8629fa3f18 core: bring back libgit2 certificate callback
Turns out that at least on Android libgit2 sometimes rejects valid
certificates. And I cannot quite figure out when and why. But since we
actually already checked the validity of the certificate when we called
canReachCloudServer() (and the Qt code handles certificates correctly),
we'll simply ignore this here and override the check to always return
true for our cloud server.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-18 09:00:21 -07:00
Dirk Hohndel
f9f4a9c232 debug output: ensure our debug output is captured on Android
I would have bet money that Android used to send stderr to the logcat
log, but apparently it doesn't (anymore?). So in order to be able to
have a chance to debug weird cloud storage issues on Android, let's do
some wholesale replacement of fprintf(stderr,...) with our own version
of the INFO macro that we long ago borrowed from libdivecomputer (and
rename it to ensure we don't have a conflict there).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-18 09:00:21 -07:00
Robert C. Helling
39784be4e8 Fix CSV for profile export
The function to print a double did not print a comma while
the lines ended in a comma.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-04-18 13:41:29 +02:00
Berthold Stoeger
b1f8b6b950 profile: avoid double-free when reusing plot_info
free_plot_info_data() freed the pressure-data, but didn't set the
value to NULL. Thus, when the plot_info was reused, a double-free()
could ensue.

Crash condition: export the profiles of multiple dives with pressure
data.

Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-18 11:17:32 +02:00
Dirk Hohndel
f24cbbcb2c git-storage: add additional debug output
This helps the user figure out why we weren't able to write a tree.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-15 07:58:10 -07:00
Dirk Hohndel
2f8f6c4fa1 git-storage: add helper function to delete remote branch
This will be used by the test to clean up test branches that are created
on the server. Since we aren't testing that functionality (it's not
something that Subsurface itself ever does) the helper prints out errors
it encounters, but doesn't report them back to the caller.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-15 07:58:10 -07:00
Linus Torvalds
f4ffd7a8fb git-storage: fix up old broken local caches to use the right branch
If you had one of the unfortunate local git caches with a local HEAD
just pointing to 'master', this will make note of that and then fix it
up to use the proper branch name in the cache repository.

[Dirk Hohndel: demoted from error to fprintf as most users won't care]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-15 07:58:10 -07:00
Linus Torvalds
433149af19 git-storage: make creation of empty cache repo set the initial branch
In create_and_push_remote(), we set up the remote tracking etc to use
the proper branch name, but never actually set up the initial local
branch for the new cache repository at all.  So the repository would end
up with the default 'master' branch, instead of the branch name it
should have.

This went unnoticed, because most setups start by initializing the git
caches by cloning from the cloud, and that worked fine.

Debugged-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-04-15 07:58:10 -07:00
Berthold Stoeger
103951bc78 divelist: when removing/adding a dive unregister/register fulltext
This fixes a crash: when the undo commands removed a dive from
the list, the fulltext cache was not cleared. If now the divelist
is reset and then the undo-command deleted, deletion of the owned
dive tries to remove it's fulltext cache, which doesn't exist
anymore.

For reasons of symmetry, when readding the dive, its fulltext
has to be registered.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-13 08:52:48 -07:00
Berthold Stoeger
8b93d67106 mobile: remove fine-grained notification
When initializing the fulltext-cache and the dive-list, every
100 dives a notification was shown. I had a feeling that this
made startup significantly slower, but that could have been
purely psychological.

Therefore I measured and indeed, removing the fine-grained
notification, it becomes *significantly* faster. For a 3500
dives test log with mobile-on-desktop:

Initialization of the fulltext: 1350 ms -> 730 ms (-46%)
Initialization of the divelistmodel: 689 ms -> 113 ms (-83%)

Let's remove the fine-grained notification. There *is* a visual
indication of work-in-progress anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-13 08:30:51 -07:00
Robert C. Helling
9feda56006 Remove extra argument and add a test
The compiler complained about this and it seems the
function does not need it.

Additional-test-suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-04-13 09:42:29 +02:00
Robert C. Helling
b50d5b63ad Preserve events when editing dive in planner
The planner does not know about events except gas
changes. But if the dive comes from the log, we
should preserve the dive computer events. At least
those that happend before we started to delete
waypoints to let the planner take over.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-04-13 09:42:29 +02:00
Robert C. Helling
1690ba7c0c Fix compiler warning about variable length field not last in struct.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-04-13 09:42:29 +02:00
Berthold Stoeger
f3b817c2d5 media: invalidate correct dive when removing picture
This fixes a bug: when deleting a picture when multiple dives
were selected, possibly the wrong dive was invalidated.
Thus, the dive wouldn't have been saved to the git repository.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-11 11:12:33 -07:00
Dirk Hohndel
6d187b5f4a
Merge pull request #2643 from bstoeger/cylinder4
First steps of cylinder-editing undo
2020-04-11 11:03:05 -07:00
Dirk Hohndel
1c420dc64a
Merge pull request #2736 from Subsurface-divelog/removeCloudOverride
core: remove cloud certificate override
2020-04-10 17:22:06 -07:00
Dirk Hohndel
61f9c4114e
Merge pull request #2737 from Subsurface-divelog/libgitCleanup
Libgit cleanup
2020-04-10 17:19:51 -07:00
Dirk Hohndel
fe6ecb4cd8 code cleanup: once we find a match, stop checking
This isn't really a useful performance improvement, but it's still better,
IMHO, because we don't have a less specific match later on potentially change
an already executed match.

Because of our coding style the comment covering multiple cases of Pelagic dive
computers now is associated just with the first of those entries. I don't see a
way to do this differently without being in violation of our coding style, so
I'll just keep it like this.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-10 17:18:17 -07:00
Dirk Hohndel
55bbdc2728 BLE dive computer detection
Both Shearwater Petrel and Petrel 2 identify as 'Petrel' as their BT and BLE
names. But only the Petrel 2 supports BLE, thus only the Petrel 2 shows up in
the list of known dive computers on iOS (which supports only BLE but not
BT-only). By switching this around to always pick Petrel 2 we now correctly
detect such a dive computer on iOS.

Fixes #2739

Reported-by: Rick Holcombe <wrh@nc.rr.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-10 17:18:17 -07:00
Dirk Hohndel
b241d09694 mobile/models: correctly reset the connection model
Qt hates empty ranges, and even for a non-empty range, this is better
implemented as a reset than a remove.

This fixes a crash that I have been able to create on iOS by rescanning
for devices on the download page.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-10 17:18:17 -07:00
Berthold Stoeger
3f3869ff65 media: move picture function from dive.c to picture.c
Currently, move only those functions that do not access dive
structures.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-10 10:53:03 -07:00
Berthold Stoeger
34657f62ae cleanup: remove picture_free()
There is the free_picture() function with the same functionality.
The compiler/linker should recognize that and remove the duplicate
code, but still...

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-10 10:53:03 -07:00
Berthold Stoeger
aa8cadbcdd cleanup: remove dive_get_picture_count() function
The last user was removed in 5b7e4c57f7.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-10 10:53:03 -07:00
Dirk Hohndel
53fb533a99 cloud-storage: create consistent commit message for merges
This never made sense and I think I just forgot to complete this code
when I first worked on it. Now we can see which version of Subsurface or
Subsurface-mobile created a merge.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-10 09:53:24 -07:00
Dirk Hohndel
7a238b6146 cloud-storage: simplify creation of git authorship
While having the local user information in the repo on Linux seemed
clever when we implemented it, it's inconsistent with all the other
platforms. Let's just not do that unless the user has indeed set
a global name/email pair for git.

Instead indicate if this was Subsurface or Subsurface-mobile.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-09 17:05:44 -07:00
Dirk Hohndel
67a717dc05 cleanup: remove support for ancient versions of libgit2
We require a minimum of libgit2 0.26.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-09 17:05:30 -07:00
Dirk Hohndel
ccbd4d1916 core: remove cloud certificate override
This code stopped being useful a long time ago.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-09 13:54:43 -07:00
Berthold Stoeger
3a74f65063 fulltext: don't call words.clear() in FullText::populate()
This function was not meant to be called with already existing data.
However, if it was, it cleared the words without clearing the fulltext
caches of the dives. This lead to crashes.

Be more resilient by not clearing the words: Already existing dives
are unregistered during the process of populating anyway. So this
now *should* work if new dives are added to the dive list and then
this function is called.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-08 08:08:19 -07:00
Berthold Stoeger
d9599589c7 fulltext: rename fulltext_reload() to fulltext_populate()
This function was named improperly: it was only used on freshly
loaded data. Indeed, attempts to use it to actually reload lead
to crashes.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-08 08:08:19 -07:00