Commit graph

15940 commits

Author SHA1 Message Date
Berthold Stoeger
25b30da244 Profile: properly initialize plot_info structures
The create_plot_info_new() function releases old plot data. This
can only work if the plot_info structure was initialized previously.
The ProfileWidget2 did that by a memset, but other parts of the code
did not.

Therefore, introduce a init_plot_info() function and call that when
generating a plot_info struct. Constructors would make this so much
easier - but since this is called from C, we can't use them.

Fixes #2251

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-28 07:10:09 -07:00
Stefan Fuchs
0e55739f03 Show surface degassing in the planner only when configured time != 0
This prevents from useless "Air" tag in profile when this feature is
not used.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2019-08-26 13:19:06 +02:00
Dirk Hohndel
96f71e6cb1 Update README and ReleaseNotes for 4.9.2
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-24 15:04:54 -07:00
Dirk Hohndel
92a2a20d16 Update list of supported dive computers
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-24 15:04:54 -07:00
Dirk Hohndel
7501e7b311 Latest translations
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-24 15:03:27 -07:00
Linus Torvalds
d570cb789f Update libdivecomputer to support the Aqualung i200c
I got confirmation from Tiago Thedim Dias that my libdivecomputer patch
makes BLE downloading work from the i200c, and already pushed out the
libdivecomputer changes earlier.  This updates the subproject in
subsurface to have those changes.

This also adds the bluetooth name patterns for the i300c and a few other
Aqualung dive computers we hadn't added yet.  That should make them show
up in the bleutooth device list even without having to check the "Show
all bluetooth devices" check-box.

Tiago claims he didn't need that, and I wonder if we have some overly
permissive match somewhere, but it's the right thing to do regardless.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-24 15:02:50 -07:00
Berthold Stoeger
6cb0de4060 CHANGELOG.md update
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-24 14:00:06 -07:00
Berthold Stoeger
97380d6a36 Desktop: fix crash on copy & paste
The constructor of PasteState was clearing an uninitialized
weightsystem-table. Very silly. Initialize it instead.

Fixes #2253

Reported-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-24 14:00:06 -07:00
Berthold Stoeger
e6cd4f8ae5 Grantlee: generate vector of cylinder data on-demand
Instead of generating cylinder data in the form of
CylinderObjectHelper objects for every DiveObjectHelper,
generate it only if needed. DiveObjectHelper is used extensively
in the mobile interface, which doesn't use the cylinder data.
Let's not generate unnecessary CylinderObjectHelpers in this
case!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-22 10:13:40 -07:00
Berthold Stoeger
f25fa2adc5 Cleanup: turn CylinderObjectHelper into value type
CylinderObjectHelper is used for structured formatting of cylinder
values in grantlee types. Instead of keeping a reference to a
cylinder, turn it into a value type containing the formatted strings.

This should be distinctly safer, as we don't risk having stale
references flying around. Moreover, we don't have to use pointers
but can use containers containing plain CylinderObjectHelper. Thus,
no explicit memory management is needed, making the code distinctly
easier to understand.

Sadly, currently grantlee does not support Q_GADGET based Q_PROPERTY.
Therefore a GRANTLEE_*_LOOKUP block has to be added. This can be
removed in due course, as a patch to remedy this issue is in current
grantlee master.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-22 10:13:40 -07:00
Berthold Stoeger
0d045f8c14 Cleanup: don't include dive.h in CylinderObjectHelper.hpp
This only needs the declaration of cylinder_t, which is
found in equipment.h

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-22 10:13:40 -07:00
Robert C. Helling
a0912b38bd Replace table interpolation by two line fit for CNS
We used a table lookup for CNS equivalent times. Turns
out the log of this table falls pretty much on a straight
line for po2 <= 1.5bar. We now fit this tabel two two
lines, one for <= 1.5 bar and one above. This four
parameter fit has half the sum of errors squared
than the five parameter fit using a fourth order
polynomial.

Fitting the log has the advantage that this never
crosses 0, which would have the bad effect of
resulting in negative CNS values as we divide
by the table value.

We don't adopt a maximum pO2 cut-off for the CNS calculation
but rather live with the large values that the interpolation
formula produces when extrapolating.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-08-20 18:32:07 +02:00
Linus Torvalds
1f24a8ef82 Update to latest libdivecomputer
Add support for Deepblu Cosmiq+

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-19 13:42:01 -07:00
Linus Torvalds
8c408da9ab Fix the dive site XML saving
It turns out that the dive site saving was subtly but horribly buggy.
To save the value of the dive site, it did

    show_utf8_blanked(b, t->value, " value='", "'/>\n", 1, anonymize);

which looks sane on the face of it, but the problem is that it puts the
final closing xml marker in the 'append this at the end' case.

That means that if the value is empty, the value won't be saved, but
neither will the closing tag.  Resulting in an xml line that looks like
this:

  <geo cat='3' origin='0'  <geo cat='5' origin='0' value='Other name'/>

where the first geo tag was saved without the ending marker.

That then makes all the xml nesting entirely wrong, and the whole file
fails to save.

Now, the code around it does check that 't->value' is not NULL, but it
doesn't check for a value that is empty or all spaces (which also will
make 'show_utf8()' just skip it.

Fix it by saving the end marker separately:

    show_utf8_blanked(b, t->value, " value='", "'", 1, anonymize);
    put_format(b, "/>\n");

so that the xml is valid even if the goe marker value wasn'r.

Reported-by: Bob Barker <barkerb1965@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-19 12:28:20 -07:00
Dirk Hohndel
5ffca686c2 Desktop: show local git repos in recent files
But don't show our cloud storage entry (as that is already in the File menu,
anyway).

This is extremely useful because while you can manually enter a file name to
save to (and therefore can use the 'magic' git repo syntax), on most OSs there
is no way to enter that non-existing 'file name' (which is the git branch in
square brackets) in the file open dialog.

Fixes: #2236

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-18 23:37:17 +03:00
Linus Torvalds
25db28b905 Add BLE name recognition for the Deepblu Cosmiq+
It needs a newer version of libdivecomputer to actually download, but
early very experimental code exists in the Subsurface-NG branch.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-18 23:28:48 +03:00
Berthold Stoeger
14dd93b655 Mobile: fix bound check in DiveListModel::data()
Indexes go from 0 to count - 1. Thus, the comparison for invalid
indexes has to read ">= count", not "> count".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-13 07:27:48 -07:00
Berthold Stoeger
62cbfc3325 DiveObjectHelper: warn if object is generated from the null pointer
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-12 16:28:49 -07:00
Berthold Stoeger
88119b356d DiveObjectHelper: remove default argument
We don't support null-dives in DiveObjectHelper. Defaulting the
dive parameter to NULL seems to send the wrong message.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-12 16:28:49 -07:00
Dirk Hohndel
c43e5f648c Add CHANGELOG entry for mobile weight editing
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-11 12:23:57 -07:00
Dirk Hohndel
0eb14828b5 Mobile: use a default weight name when adding weight system
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-11 12:23:33 -07:00
Berthold Stoeger
6b92edc9ab Mobile: support editing of dives with no weightsystem
If a dive has no weightsystems, editing the weight system has to add
a new entry in the table. Implement that.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-11 12:23:33 -07:00
Berthold Stoeger
75be9e727d Mobile: properly recognize single-weightsystem dives
When removing the max-weightsystem restriction, the semantics of
the DiveObjectHelper::singleWeightSystem() function changed:
it now returned false for "no weightsystem". Change it back,
to 0 or 1 weightsystems, because the mobile frontend uses this
to check whether it can edit dive systems.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-11 12:23:33 -07:00
Doug Junkins
624ab3bf9e Add missing header files to macos.c
Missing header files were causing errors opening cloud storage on
launch on Mac OSX.

Signed-off-by: Doug Junkins <junkins@foghead.com>
2019-08-11 08:20:38 +02:00
Dirk Hohndel
e9194a5c40 Fix potential crash when saved_git_id is NULL
We have a safe strdup alternative. Let's just use it.

Fixes #2220

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-10 20:59:53 +02:00
Dirk Hohndel
7eadc8ef7e Android: fix potential crash
I'm not sure about this one, as we test name at the start of the
function and event->name shouldn't be NULL, but hey, we have the safe
compare function, so let's use it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-10 20:59:53 +02:00
Berthold Stoeger
f3acb0ca02 Mobile: catch null references in DownloadDCThread
There are reported crashes on Android that suggest a null
"tables" attribute in DownloadDCThread. This should never
happen, as the table() function connected to this attribute
returns the address of a subobject. Thus, even if the original
DownloadThread is null, this would not return a null pointer
(the subobject is not at address 0).

Catch these null-object accesses and write a warning message
to the console. Hopefully, this will help is localizing the
problem.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-10 09:58:19 -07:00
Berthold Stoeger
0cce3ef2a8 Mobile: update dive site model if dive sites are created
Always keep the dive site model up to date when adding dive sites.
This hopefully avoids creation of invalid indexes followed by crashes.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-10 09:55:11 -07:00
Berthold Stoeger
f18ea2e3b6 Location model: treat invalid indexes gracefully
There have been crash reports in DiveSiteSortedModel::allSiteNames().
The only conceivable reason that this crashes is that the core knows
about more sites than the model and therefore on mapToSource() we
get an invalid index, which is translated to -1. Accessing the name
of that dive site will crash.

Handle such invalid indexes gracefully.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-10 09:55:11 -07:00
Berthold Stoeger
309a8c5b14 Core: unconditionally include stdio.h in libdivecomputer.h
Header files should compile regardless of order of inclusion.
Since libdivecomputer.h uses FILE unconditional include of
stdio.h is the correct thing to do.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-10 09:16:01 -07:00
Dirk Hohndel
302b39bcd5 iOS: address build error
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-08 17:38:47 -07:00
Berthold Stoeger
e921715410 Planner: pass dive to enough_gas()
Enough gas was checking the currently displayed dive instead of the
dive to be planned. Not good in a multi-threaded context. Pass the
actual dive instead.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08 16:26:31 -07:00
Berthold Stoeger
7cfe1639b5 Planner: pass dive / cylinder pair to track_ascent_gas()
Pass the dive to be planned to track_ascent_gas and don't use
the displayed_dive. For convenience, pass the cylinder-id, since
the function can now access the cylinder of the dive by itself.
This makes the callers less verbose.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08 16:26:31 -07:00
Berthold Stoeger
ff40afc1d8 Planner: pass dive to analyze_gaslist()
Use the actual planned dive, not the displayed dive in analyze_gaslist().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08 16:26:31 -07:00
Berthold Stoeger
90ea46ff31 Planner: fix comment for create_dive_from_plan()
The function comment talks about overwriting displayed_dive, when
in reality the function overwrites a passed in dive.

Also fix a debug-call which dumped the displayed_dive, not the
actual dive to stdout.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08 16:26:31 -07:00
Berthold Stoeger
00944f7a02 Core: pass dive, cylinder-id to fill_default_cylinder
The fill_default_cylinder() function calculated the MOD based
on the currently displayed dive. This does not seem to make sense:
- When importing dives, why would we care about the altitude and
  salinity of the currently displayed dive, possibly from a different
  trip.
- The planner is supposed to be thread-safe and should not touch
  global variables.

Of course this means that the importing-functions have to fill
out altitude and salinity before creating the default cylinder,
but this is their problem. For a freshly created dive they will
get the default values, which still seems less random than the
values from the displayed dive.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08 16:26:31 -07:00
Berthold Stoeger
6ce4aeb04e Planner: use planner's dive in interpolate_transition()
Instead of passing the global displayed_dive to
calc_crushing_pressure(), use the dive the planner is working on.
A small step in making the planner thread-safe.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08 16:26:31 -07:00
Berthold Stoeger
ddff68ddae Parser: remove global state
The parser had global state in the form of a linear regression
and the "plot_depth" variable. Collect that in the deco_state struct and
pass it down the call-chain. Move out the code to update the
regression data to not bother other callers of tissue_tolerance_calc().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-08-08 16:26:31 -07:00
Berthold Stoeger
852239e6de Cleanup: remove unused function printdecotable
It is unclear where this function has ever been used.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08 16:26:31 -07:00
Berthold Stoeger
3d4ef92717 Cleanup: make local functions in planner.c of static linkage
A number of functions were not used outside of planner.c.
Make them static.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08 16:26:31 -07:00
Berthold Stoeger
52e5d9c605 Cleanup: move planner/deco related declarations planner/deco.h
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08 16:26:31 -07:00
Berthold Stoeger
594d1d3514 Cleanup: move file-related function declarations to file.h
A number of architecture-dependent functions were declared in
dive.h. Move them to file.h so that not all file-manipulating
translation units have to include dive.h. This is a small step
in avoiding mass-recompilation on every change to dive.h

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08 16:26:31 -07:00
Berthold Stoeger
5da09a21bb Cleanup: move error reporting function declarations to errorhelper.h
Move the declarations of the "report_error()" and "set_error_cb()"
functions and the "verbose" variable to errorhelper.h.
Thus, error-reporting translation units don't have to import the
big dive.h header file.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08 16:26:30 -07:00
Berthold Stoeger
2a966ac2a9 Cleanup: replace macro by inline function in gas-model.c
Replace a macro calculating a degree-three polynomial by an
inline function.

Moreover, calculate the powers 1, 2 and 3 of the pressure inside
the function. The compiler will be smart enough to optimize this
to the same code. The only important thing is to write "x*x*x*coeff"
instead of "coeff*x*x*x". The compiler can't optimize the latter
because ... wonderful floating point semantics.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08 15:22:09 -07:00
willemferguson
78f425de68 Move the Suit text box from the Notes tab to the Equipment tab
Sqash latest commit with previous one.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2019-08-08 09:12:09 -07:00
willemferguson
9a562f221a Desktop user manual: dc management
The relevant text in the present manual is obsolete. Update
the text dealing with dive profiles from several sive computers
for one specific dive. One image is added.

Deal with creating a new cylinder type.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2019-08-08 09:05:09 -07:00
Berthold Stoeger
344c85f499 Desktop: display trip time on main-tab
On the main tab, the trip time was not shown when switching to
a trip. Implement showing of the trip date in a function, as the
undo-code will also have to update the trip date in certain
circumstances.

Fixes #2207

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08 09:03:33 -07:00
Robert C. Helling
826387a4b0 Indicate negative cylider pressure
The planner can produce negative cylinder pressures when
more gas is used than available. Let's color the pressure
graph in a highly visible color to alert the user of the
fact that current gas planning is insufficient.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-08-08 08:56:44 -07:00
Robert C. Helling
f1fc328355 Fix math in valueAt
DiveCartesianAxis::valueAt() is supposed to be the inverse of
posAtValue(). This fixes the math such that inverted
orientations are correctly taken care of.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-08-08 08:56:44 -07:00
Linus Torvalds
a8b1c86139 Limit gas compressibility argument range to halfway sane values
The curve fitting for our gas compressibility was only done in the sane
range of 0-500 bar, which is what a scuba cylinder can reasonably be
expected to perhaps have.

But the planner ends up happily using negative cylinder pressures when
you run out of gas, and then the compressibility gives nonsensical
results.

That's clearly a planner bug, but the nonsensical gas compressibility
values made it harder to see what could be wrong.

So we just clamp the inpot range to the range we have verified against
experimental data.  If you try to get compressibility for negative
pressures, you get the compressibility for an ideal and imaginary gas.
And if you try to get compressibility for pressures over 500 bar, we'll
just assume that it's 500 bar.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-08 09:07:48 +02:00