Commit graph

1820 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
Berthold Stoeger
ba4d6ae627 Cleanup: use clear_git_id() instead of setting saved_git_id
For better encapsulation, use clear_git_id() in clear_dive_file_data()
instead of setting saved_git_id directly.

Thus, memory management of the saved_git_id value is encapsulated
and can be modified more easily.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-04 16:22:19 -07:00
Berthold Stoeger
891d21b34e Coding style: add spaces in load-git.c
Add spaces before and after multiplication and addition operators.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-04 16:22:19 -07:00
Berthold Stoeger
3fe80bfd79 Git: Make parser reentrant
The git parser was using a number of global static variables. Remove
them by introducing a parser state, which is passed down to the
call hierarchy.

Advantages:
1) Removes global variables and makes the parser (mostly) reentrant.
2) More flexible - e.g. when parsing samples, the parser can now
   access the dive to check if the cylinder number is valid.
3) Less weak typing through "void *".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-04 16:22:19 -07:00
Berthold Stoeger
f756dcbf94 Cleanup: make functions in core/load-git.c local
The function get_divemode() and git_tree_entry_blob() were not used
outside of load-git.c. Make them of static linkage.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-04 16:22:19 -07:00
Berthold Stoeger
a0cd89f850 Core: split copy_cylinders() in two functions
copy_cylinders() copied the cylinders of one dive onto another dive
and then reset to the original gas values. Presumably, when copy and
pasting cylinders from one dive to another, only the types should
be copied, not the gases.

Moreover, the function could either copy all or only the used cylinders.

Firstly, the code was bogus: when restoring the pressures the indices
were mixed up: the old indices were used. Thus, when there where
uncopied cylinders, not all pressure values were restored.

Secondly, it is not clear that all callers actually want to restore
the pressure data. It rather appears the two (out of three) callers
actually just want to copy the cylinders.

Therefore, split the function in
  1) copy_cylinders(): copy the cylinders with pressure data
  2) copy_cylinder_types(): copy only the cylinder information

Since there is only one caller of copy_cylinder_types(), the "used_only"
argument can be removed. Since all cylinders are copied there is
no point in storing the pressure data. Don't overwrite it in
the first place.

The resulting two functions should be distinctly easier to understand.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-27 11:55:05 -07:00
Dirk Hohndel
52cb38e540 Bluetooth: autodetect Shearwater NERD models
This should allow it to work with Subsurface-mobile as well.

Fixes #2187

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-07-19 21:50:36 -07:00
Berthold Stoeger
94521c9958 Cleanup: remove bogus mark_divelist_changed() calls
The parsers / downloaders parse into a separate table and do
not directly change the divelist. Therefore, they shouldn't
call mark_divelist_changed().

Likewise split_dive_at() doesn't modify the dive list and
therefore shouldn't call this function.

Calling the function has the unwanted side-effect that undoing
the change will not clear the *-symbol in the title of the
main window.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-19 21:44:13 -07:00
Berthold Stoeger
3bb60e8ffe Cleanup: remove unused weightsystem_none() function
This function was used to count the number of weightsystems
used in a dive. Since the weightsysems are now collected
in a dynamic table it became unused. Remove.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 06:01:07 -07:00
Berthold Stoeger
a5e7f4253a Core: dynamically resize weight table
Replace the fixed-size weightsystem table by a dynamically
relocated table. Reuse the table-macros used in other parts
of the code.

The table stores weightsystem entries, not pointers to
weightsystems. Thus, ownership of the description string is
taken when adding a weightsystem. An extra function adds
a cloned weightsystem at the end of the table.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 06:01:07 -07:00
Berthold Stoeger
efdb3503ea Core: Implement same_weightsystem() function to compare weights
This will be used later when joining and editing dives.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-07-18 06:00:58 -07:00
Berthold Stoeger
ca4103ea6a Cleanup: declare functions in profile.h as extern
We seem to do this in other C-headers, so for consistency also do
it here.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:50:22 -07:00
Berthold Stoeger
f145b116f0 Cleanup: make the plot-pressure type an enum
Sadly, this doesn't give any type safety. But at least it documents
the function arguments.

Make the last item in the enum as a number-of-pressure-entries
sentinel. Use that to size the pressure-values array.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:50:22 -07:00
Berthold Stoeger
39ede7e9e8 Cleanup: introduce function to set pressure values
Instead of assigning the the lvalue of the SENSOR_PRESSURE
macro, introduce a general function to set pressure values.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:50:22 -07:00
Berthold Stoeger
68147c4225 Cleanup: update comment in core/gaspressures.c
The comment to populate_pressure_information() was mentioning
gas pressures that didn't exist. Remove these parts.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:50:22 -07:00
Berthold Stoeger
469cc68b02 Cleanup: replace pressure reading macros by inline functions
Replace the INTERPOLATED_PRESSURE and SENSOR_PRESSURE macros by
inline functions. Generate a common inline function that reads
a pressure value for a dynamic sensor.

Not all SENSOR_PRESSURE macros can be replaced, because the
macro is also used to set the value and C sadly doesn't know
the concept of "return reference from a function".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:50:22 -07:00
Berthold Stoeger
29005b578d Cleanup: turn GET_PRESSURE macro into inline function
There is absolutely no reason to use a macro here.
The only argument that can be made is consistency with
the other pressure-macros, but those too are questionable.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:50:22 -07:00
Berthold Stoeger
1eafd500e3 Cleanup: remove non-existing pressures in debug_print_pressures()
DILUENT_PRESSURE and INTERPOLATED_DILUENT_PRESSURE do not exist
anymore. No point in trying to output them.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:50:22 -07:00
Berthold Stoeger
34b3a13f38 Cleanup: remove unused macro SAC_WINDOW
Last user was removed in ae1e9b11a5

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:50:22 -07:00
Berthold Stoeger
8f119dcf72 Cleanup: remove includes from qthelper.h
To reduce interdependencies, remove the dive.h and divelist.h
includes in qthelper.h

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:42:55 -07:00
Berthold Stoeger
0136d76cf4 Cleanup: move deco function declarations to deco.h
Another tiny step in making dive.h smaller: move function
declarations to deco.h if these functions are defined in deco.c
and don't directly concern dives.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:42:55 -07:00
Berthold Stoeger
b720f36978 Cleanup: fix include weirdness concerning string_to_*() functions
The string_to_*() functions were declared in dive.h and qthelper.h.
Moreover in one file they were declared with C in the other with
C++ linkage. This only works because qthelper.h includes dive.h
first.

Fix this anomaly by declaring the functions only in qthelper.h,
but moving them from the C++ to the C part.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:42:55 -07:00
Berthold Stoeger
b862e028c6 Cleanup: move cylinderuse_from_text() to equipment.c
Since this function doesn't act on a dive and is only related
to cylinders, move it to equipment.c and equipment.h.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:42:55 -07:00
Dirk Hohndel
3e5d60d95a Bluetooth: recognize Ratio iX3m GPS dive computers
We cannot tell them apart by Bluetooth name, so pick one of the names.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-07-15 11:18:32 -07:00
Linus Torvalds
36121fd8ae Fix up XML saving of remaining bottom time data
While testing the cylinder type saving fix, I noticed that the RBT
saving was broken.  Instead of saving RBT whenever it changed, we'd save
it when it was non-zero.  Which doesn't match the git save format, and
also doesn't match what we do when loading an xml file (where we default
to the previous RBT value, and a sample RBT will modify it).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-07-14 22:17:13 +02:00
Linus Torvalds
c685c05ff4 Fix cylinder gas type saving when we have bogus gas use data
Steve Williams reported a crash when saving a previously loaded dive as
xml, and gave a gdb backtrace.

It turns out that if we can't parse the cylinder use type (OC, diluent,
oxygen, unused) we initialize the cylinder use to an invalid type, and
then when we save it, we mess up.

Fix it up by doing proper limit checking before accessing the
"cylinderuse_text[]" array when saving.

Reported-by: Steve <stevewilliams@internode.on.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-07-14 22:17:13 +02:00
Berthold Stoeger
92dc441f02 Thumbnailer: improve error message
In the error messages shown when failing to start ffmpeg, instruct
the user to set the correct executable in the preferences.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-11 00:24:23 +09:00
Berthold Stoeger
9eb860d45d Git: handle excess of cylinders or weightsystems gracefully
Currently, the git parser happily trashes memory if a git repository
contains too many weightsystems or cylinders. This should only happen
in testing, but nevertheless try to handle it gracefully and ignore
excess cylinders / weightsystems.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-10 05:11:47 +03:00
Berthold Stoeger
ae60fdf815 Cleanup: call calculate_max_limits_new() in create_plot_info_new()
All callers of create_plot_info_new() called calculate_max_limits_new()
a line before. Thus, simply call the latter in the former.

This allows us to automatically free the plot data in create_plot_info_new().
The old code overwrote the corresponding field with NULL.

As a side-effect, this removes a bogus static variable.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-06 11:23:35 -07:00
Berthold Stoeger
69be1e23f2 Cleanup: fix memory management of the plot data
There was a global variable last_pi_entry_new, which stored the
recently allocated plot data. This was freed when new plot data
was generated.

A very scary proposition: You can never have two plot datas at
the same time! But exactly that happens when you export for
example subtitles.

The only reason why this didn't lead to very crazy behavior
is that at least on my Linux machine, the calloc() call would
just return the previously freed memory.

Fix this mess by removing the global variable and freeing the
data in the callers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-06 11:23:35 -07:00
Berthold Stoeger
5e9ffe3005 Cleanup: remove unused get_screen_dpi() function
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-06 04:10:14 -07:00
Berthold Stoeger
675288f711 Cleanup: remove unused declarations from display.h
A number of declarations were not used anywhere. Remove them.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-06 04:10:14 -07:00
Robert C. Helling
5c1446a87a Planner: Wait minimum switch time when bailing out to OC
Bailing out does not happen instantly. Rather wait for
the minimum stop switch duration before ascending.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-06-28 15:58:52 +02:00
Berthold Stoeger
d60ec98e8e Cleanup: remove includes from extern "C" block
In "core/save-html.h", the "core/dive.h" header was included in the
extern "C" block. This is invalid, because "core/dive.h" included
from C++ code contains Qt macros that expand to C++ templates. These
in turn must not have extern "C" linkage, since a plain C-linker
cannot handle such things.

The only reason this worked is that in all cases "core/save-html.h"
was included after "core/dive.h". The include of the latter in the
former had therefore not effect.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-28 20:18:02 +09:00
Berthold Stoeger
9e1d83ca56 Import: use TRIP_THRESHOLD when checking for trip-overlap
When checking for trip-overlap on import, only really overlapping trips
have been considered, i.e. when dives had overlapping times.

Instead use the TRIP_THRESHOLD so that on download dives are added to
the same trip if in a two-days time frame.

Reported-by: Miika Turkia <miika.turkia@gmail.com>
Reported-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-28 20:13:49 +09:00
Berthold Stoeger
2e230da361 Cleanup: unify selection signals
For historic reasons, there where three distinct signals concerning
dive-selection from the undo-machinery:
1) divesSelected: sent newly selected dives
2) currentDiveChanged: sent if the current dive changed
3) selectionChanged: sent at the end of a command if either the selection
   or the current dive changed

Since now the undo-commands do a full reset of the selection, merge these
three signals into a single signal.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-23 20:08:46 +02:00
Berthold Stoeger
e1abf9485c Undo: unify selection behavior in dive-list commands
Some commands tried to retain the current selection on undo/redo,
others set the selection to the modified dives.

The latter was introduced because it was easier in some cases, but
it is probably more user-friendly because the user gets feedback
on the change.

Therefore, unify to always select the affected dives on undo()/redo().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-23 20:08:46 +02:00
Berthold Stoeger
27944a52b1 Undo: don't send signals batched by trip
Since the default view is batched by trips, signals were sent trip-wise.
This seemed like a good idea at first, but when more and more parts used
these signals, it became a burden. Therefore push the batching to the
part of the code where it is needed: the trip view.

The divesAdded and divesDeleted are not yet converted, because these
are combined with trip addition/deletion. This should also be detangled,
but not now.

Since the dive-lists were sorted in the processByTrip function, the
dive-list model now does its own sorting. This will have to be
audited.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-23 20:08:46 +02:00
Berthold Stoeger
12a13d722a Undo: sort dives by dive_less_than() in signals
In signals dives were sorted by date. This criterion is not be unique.
Therefore sort by the dive_less_than() function of the core to avoid
any inconsistencies between the Qt-models and the core data.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
b7ff069b02 Cleanup: remove unused macros WEIGHT_IDX_PRIMARY and _SECONDARY
Last users were removed in 34db6dc2be.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
7bfec6fa19 Cleanup: use total_weight() in DiveObjectHelper::sumWeight()
Don't reimplement the summation of weights.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
3e88bd686f Cleanup: remove unused parameter used from find_best_gasmix_match()
The last direct user of the used parameter was removed in
16276faa45, the last actual user in
e2bbd0ceec.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
219c230506 Cleanup: constify two equipment helper functions
add_cylinder_description() and add_weightsystem_description() don't
modify their input parameter. constify them.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
d129085b59 Cleanup: use add_to_dive_table() in record_dive_to_table()
This was reimplementing functionality that was already there.
Simply call the already existing function.

Thus, we don't have to export the grow_dive_table function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
3df32044ee Cleanup: generate clear_*_table() functions by macro
In analogy to the other table functions, generate these by
a macro as well.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
f4ef1c4bc8 Cleanup: localize enum and table in divelist.c
The cns_table was only used in divelist.c. Make it of static
linkage accordingly.

The cns_table_headers enum is likewise only used in divelist.c.
Therefore move it from the header to the .c file.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
821f68550d Cleanup: make local variables and functions in deco.c static
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
e2937f0614 Cleanup: move function declaration into header file
The function declarations of regressiona(), regressionb() and
reset_regression() were given in an independent translation unit.
Move them into the proper header file. To ensure consistent function
signatures is the whole point of header files, after all.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
5514047b43 Cleanup: remove unused global variables plangflow and plangfhigh
The last user was removed in 1093d6235b.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
ef8c5cd9ab Cleanup: make lookup table in planner.c of static linkage
The lookup tables decostoplevels_metric and decostoplevels_imperial
in planner.c were not used outside the translation unit. Make them
static.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
afd6c66346 Cleanup: remove unused function find_dive_including
Last caller was removed in 7eb422d988.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
af5aa8a23d Cleanup: Make gaspressures.h a regular include file
gaspressure.h had definitions of non-exported structs, but did
not declare the only function exported by gaspressure.c.

Therefore, move the struct definitions into gaspressure.c and
the declarations of the populate_pressure_information() function
from profile.c to gaspressures.h.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
619d3fb1fd Cleanup: move gas-functions to own translation unit
But only functions that operate only on gases. Functions concerning
cylinders or dives remain in dive.c or are moved to equipment.c

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
8352274758 Cleanup: remove unused macro FOR_EACH_PICTURE_NON_PTR
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
ce065968f0 Cleanup: remove bogus inline modifier
gas_density() was declared extern in the header and defined inline
in the translation unit. I didn't even realize that this oxymoron
is valid. Remove inline and an Java-style function definition.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
bff80cf462 Cleanup: move unit-related functions to own translation unit
Create a units.c translation unit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
7f4d9db962 Cleanup: move trip-related functions into own translation unit
These functions were spread out over dive.c and divelist.c.
Move them into their own file to make all this a bit less monolithic.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
f1c2cd375e Cleanup: move TRIP_THRESHOLD into divelist.c
This macro was not used elsewhere.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
529bdef0d6 Cleanup: create equipment.h header
There is an equipment.c file, but no corresponding header. Move the
corresponding functions into a newly created header. This does not
improve compile time since, at least for now, equipment.h is included
in dive.h. But it makes things more consistent.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
27d7f27409 Cleanup: fix comment to STRUCTURED_LIST_FREE
The comment said "Clear everything but the first element" but
actually the macro freed the whole list including the first element.
For dive computers it was explicitly called on the second element.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
6200909ba4 Cleanup: move tag functions into own translation unit
Make dive.h a bit slimmer. It's only a drop in the bucket - but at
least when modifying tag functions not the *whole* application is
rebuilt anymore.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
46c69fccb7 Cleanup: fix includes in membuffer.h
Headers should not have to be included in a certain order.
Therefore include stdarg.h and stdio.h in membuffer.h, since
the latter uses FILE and va_list.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
e3304d8d7d Cleanup: use taglist_copy() instead of STRUCTURED_LIST_COPY
There is a function for copying tag-lists, use that instead of the
raw STRUCTURED_LIST_COPY macro-invocation. This will help in moving
tag functions into their own translation unit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
9b787e0606 Coding style: remove Java-style function definitions in dive.c
These stuck out like a sore thumb - let's go C-style instead.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
d3cd85b343 Cleanup: remove unused function dump_taglist()
This was probably used for debugging but has no callers anymore.
Let's remove it. If needed, it can be trivially readded.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Dirk Hohndel
16fc94301e Android: add Cressi Cartesio and Goa as potentially supported
Assuming they are connected to an FTDI cable.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-06-15 11:35:32 -07:00
Berthold Stoeger
a20c22d907 Undo: hide multi-dive-edit warning message on subsequent edit
When a different field is edited, hide any old multi-dive-edit
warning message. The reason is that we might want to add an "undo"
button to the message. But this will undo the wrong command if
we don't hide the message.

Sadly, this means that we can't use animated show / hide, because
an animatedHide() followed immediately by an animatedShow() does
not necessarily show the message. In other words, and animatedShow()
does not interupt a started animatedHide()!?

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-15 11:20:49 -07:00
willemferguson
58985cd8ae Correct typo in Information box
Correct type in SCR delta pO2 display in Information box

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2019-06-07 09:42:39 +02:00
Berthold Stoeger
cf3bb91ec0 Cleanup: remove unnecessary include in downloadfromdcthread.cpp
No QRegularExpressions were used in that file.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-06 14:52:42 +03:00
willemferguson
a592b4e143 Add delta-pO2 disply in Information Box
Add display of the difference between pO2 in rebreather loop and the
equivalent OC pO2: this is the oxygen drop over the mouthpiece for
SCR dives. Obviously this is only displayed for SCR dives.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2019-06-03 22:56:06 +02:00
Linus Torvalds
ba31c56c78 Add BLE detection for the new Oceanic Geo 4.0
Note that we don't really have libdivecomputer support for it yet, only
newly added model numbers etc.  But the name detection should make it
easier for people to at least download a memory dump.

In addition to the libdivecomputer model number updates, this also has a
merge of Jef's upstram libdivecomputer changes.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-06-01 05:25:23 +03:00
Robert C. Helling
4767349111 Update deco disclaimer
Our disclaimer is no longer "new". It is still true that people
should not blindly follow it.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-05-29 15:04:33 +03:00
Berthold Stoeger
4fe9b39cdb Core: let count_divecomputers() operate on an arbitrary dive
Currently, count_divecomputers only works on the current_dive.
Instead, let it take a pointer to an arbitrary dive. This is
in preparation for being smarter in the undo code concerning
which dive computer to show on deletion.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-20 21:23:16 -07:00
Berthold Stoeger
ac590235c9 Cleanup: rename clone_dive() to move_dive()
This function clones a dive and clear out the old dive. This
corresponds to move semantics. Name the function accordingly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-20 21:23:16 -07:00