Commit graph

18786 commits

Author SHA1 Message Date
Dirk Hohndel
383f326136 build-system: fail with Qt6
I thought that explicitly requesting Qt5 should be enough, but we have a report
from a user who tried to build against Qt6 and cmake happily let them proceed.
So let's fail this explicitly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-07-28 07:44:58 -07:00
Dirk Hohndel
42eb39fc4a changelog: add summary of recent changes
First step towards doing another release.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-07-23 11:49:24 -07:00
Dirk Hohndel
096de0efd0 core/import: fix string check logic
The intent of the code was to check that there is a string and it has at least
two characters. Since iter is the result of a strchr(iter, '|') call, we
know that if iter isn't NULL, iter[0] is '|', so we only need to check the next
character.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-07-23 11:30:17 -07:00
Dirk Hohndel
c90352008b core/csv-import: don't do pointer math after realloc
try_to_xslt_open_csv() re-allocates the memory passed in (not really great as
far as design goes, maybe something that should be reimplemented). Doing
pointer arithmatic with the returned base pointer results in garbage, unless
one gets super lucky and the realloc manages to not move the memory.

It's a wonder this ever worked.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-07-23 11:30:17 -07:00
Berthold Stoeger
846e1ba53e core: always create a fake profile if there are no samples
Before making the cylinder-table dynamic, dives always
had at least one cylinger. When such a dive is displayed,
the TabDiveInformation class calls per_cylinder_mean_depth().
If there are no samples, this function generates a "fake
profile" with fake_dc(). Thus, effectively dives always
had samples once the user was displaying them.

When the cylinder-table was made dynamic, dives without
cylinders were supported. This can notably happen, when
importing from CSV (this could actually be a bug).
per_cylinder_mean_depth() exits early in that case and
doesn't create a fake profile. This lead to crashes
of the profile-widget, which were fixed in 6b2e56e513.
Non-sample dives were now shown with the Subsurface-logo.

To restore the previous behavior, genarate a fake profile
for sample-less dives in fixup_dive(), which is called
anytime  a dive is loaded or imported. This seems to
have been the intention anyway and this worked only
"by chance". This will make a few fake_dc() calls obsolete,
but so be it.

Since fake profiles are now generated on loading,
the parse-tests need to be fixed to account for that.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-07-23 11:30:17 -07:00
Dirk Hohndel
72bdd506f0 tests: initialize our prefs to the default values
Otherwise we end up with nonsensical values which lead to a division by zero,
which in return leads to different results, depending on platform.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-07-23 11:30:17 -07:00
Berthold Stoeger
63e1516579 core: recalculate CNS values on merge
When merging two dives, the higher CNS value was taken. This could
result in inconsistent CNS values if two dives were merged where
one dive's CNS was calculated from a "fake profile", i.e. a dive
without dive-computer profile. In that case, the most conservative
value (all time spent at the bottom) was assumed. The merged dive
then consisted of the dive-computer profile and the conservative
CNS estimate.

This is fixed by setting the CNS value to "0" after merging,
which means "unknown". The correct value will then be recalculated
in "fixup_dive" from the actual sample data.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-07-23 11:30:17 -07:00
Berthold Stoeger
b18b3119b5 cleanup: don't NUL-terminate membuffer in uploadDiveLogsDE
The data of the membuffer is passed as a data/length pair
to xmlReadMemory(). There is no point in NUL-terminating it.

Moreover, pass the data directly to xmlReadMemory()
instead of via variables. These variables are reused
later with a different meaning, making this super-confusing.

The membuf variable is turned from "const char *" to "char *"
to signal that we own the buffer.

Amazingly, zip_source_buffer() frees the buffer, even though
a "const void *" is passed in. This API is pure madness. Add
a comment.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-07-23 11:22:43 -07:00
Berthold Stoeger
69914964f6 cleanup: replace membuffer by qasprintf_loc()
There is a function to format QString with C-format strings. Let's
use it instead of doing a detour via membuffer.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-07-23 11:22:43 -07:00
Berthold Stoeger
16b31985c3 cleanup: replace membuffer by membufferpp in C-code
Thus, the membuffer data is automatically freed when going
out of scope - one thing less to worry about.

This fixes one use-after-free bug in uploadDiveLogsDE.cpp
and one extremely questionable practice in divetooltipitem.cpp:
The membuffer was a shared instance across all instances
of the DiveToolTipItem.

Remves unnecessary #include directives in files that didn't
even use membuffer.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-07-23 11:22:43 -07:00
Berthold Stoeger
f142e9a9c6 core: C++-ify membuffer
C-style memory management is a pain and nearly nobody seems to get
it right. Add a C++-version of membuffer that frees the buffer
when it gets out-of-scope. Originally, I was thinking about
conditionally adding a constructor/destructor pair when compiling
with C++. But then decided to create a derived class membufferpp,
because it would be extremely confusing to have behavioral change
when changing a source from from C to C++ or vice-versa.

Also add a comment about the dangers of returned pointer: They
become dangling on changes to the membuffer.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-07-23 11:22:43 -07:00
Berthold Stoeger
0c84f369c3 core: use int16_t for sensor-id
The sensor-id in the sample struct was a uint8_t, with all
the known problems of unsigned integers. In the rest of the
code cylinder ids are signed integers. To avoid confusion,
make it a signed int. int8_t should be enough (max. 127
cylinders). To allow for degenerate cases, use an int16_t.
16k cylinders should be enough for everyone.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-07-23 11:16:00 -07:00
Dirk Hohndel
8ac0519a99 desktop: explicitly enable shortcuts
The changes in commit 4daf687876 ("profile: remove [disable|enable]Shortcuts()
signals") resulted in us no longer enabling the shortcuts on the desktop (at
least on macOS where I debugged this). This placement of the call feels like a
bit of overkill, but at least it shouldn't be wrong.

Fixes #3293

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-07-23 10:20:50 -07:00
Dirk Hohndel
c7a2d95617 Update libdivecomputer
- fix potential crash with Garmin Descent Mk2
- fix HW Sport and Mares Genius firmware update
- Various parser updates:
  - sporasub depth, salinity and sample rate parsing
  - Atomics Cobalt atmospheric pressure parsing
  - unit cleanups (Uwatec, McLean Extreme)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-07-20 09:28:38 -07:00
Dirk Hohndel
2193f09006 core/ble: add auto detection for Aladin A2
This way it will be recognized as a dive computer when it is scanned via BLE.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-07-20 09:28:38 -07:00
Berthold Stoeger
9f277e65ff cleanup: remove function static variables
There were two function-static variables in ToolTipItem::refresh(),
which is a very scary proposition. Curently, there is only
one ToolTipItem, but this may change on mobile, where there
are multiple profiles at the same time.

Remove this timebomb and make the two objects subobjects.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-07-20 09:27:35 -07:00
Berthold Stoeger
82f967ddb3 core: sanitize pressure-sensor cylinder ids in fixup_dive()
The code will happily perform out-of-bound accesses if
pressure-sensors refer to non-existing cylinders. Therefore,
sanitize these values in fixup_dive(), which is called
everytime a dive is loaded or imported.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-07-19 10:13:51 -07:00
Berthold Stoeger
361678dcbe parser: don't create samples with invalid cylinder ids
By default, the parser would create samples with cylinder
ids 0 and 1. This creates out-of-bound accesses for the
common one-cylinder (or even no-cylinder) dives. These
were harmless when the cylinder-table was of a fixed size.
Since changing to a dynamic cylinder-table, these became
actual out-of-bound accesses. Don't create such samples
in the parser.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-07-19 10:13:51 -07:00
Berthold Stoeger
7e11a35371 core: add a special NO_SENSOR value for sample::sensor
The sensor member of sample refers to a cylinder from which
the pressure was read. However, some dives don't even have
a cylinder. Therefore, introduce a special NO_SENSOR value
for these dives. Since the cylinder is given as a uint8_t,
0xff seems to be a sensible choice.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-07-19 10:13:51 -07:00
Miika Turkia
48c2929f48 Fix coverity reported memory leaks
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2021-07-19 09:07:48 -07:00
Miika Turkia
63795a84f4 Export unused cylinders to divelogs.de
When user has selected to show unused cylinders in equipment tab,
respect this setting when exporting to divelogs.de.

Fixes #3277

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2021-07-18 13:43:54 +03:00
Dirk Hohndel
235ee4803f printing: remote incorrect scaling of event icons
It appears that this well intended change in commit 52aa7d83b6 ("Increase event
icon size in print mode") actually causes the scaling of the event icons to be
generally wrong. This removes the hard 4* scaling and also adds some debugging
output in verbose mode.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-07-11 13:02:43 -07:00
Berthold Stoeger
cfc87e9da3 cleanup: remove Printer::dpi member variable
This variable is not used outside a single function, where it
is reset every time the function runs. This can be realized by
a function-local variable just as well.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-07-07 07:57:11 -07:00
Dirk Hohndel
7944978274 snap: push regular updates of dependencies to stable
We simply don't use release candidates in Subsurface these days, and no one
then moves these builds to stable after testing, so stable has been getting
stale while the builds that people SHOULD use have been sitting in candidate.

Of course, this will only become the default after our next release (as I don't
want four digit versions in a release build, so I can't simply add this to our
snap-stable branch).

Oh well - 5.0.3 will happen soon, given the print resolution issue for icons.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-07-05 10:48:30 -07:00
Berthold Stoeger
65580fceda profile: scale dive event items according to font print scale
When printing with low DPI, the dive event items become comically
large, because they are not resized like the fonts. Therefore,
scale using the fontPrintScale.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-07-04 11:51:17 -07:00
Robert C. Helling
6b2e56e513 Handle dives with no samples
This occurs upon importing dives for example via CSV.

Make sure the profile display is cleared when selecting
such a dive rather than showing a different dive.

Allow editing the profile for such a dive.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2021-07-03 14:38:19 -07:00
Dirk Hohndel
876a09753a Update translation source strings
And update all the translated copyright notices.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-07-03 14:36:59 -07:00
Berthold Stoeger
4c118f3573 profile: remove ProfileWidget2::Items
This enum was an artifact from the primordial days of the profile
widget. As far as I can see it was never used.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-07-03 14:30:46 -07:00
Berthold Stoeger
4a7cf0e970 profile: rename ADD state to EDIT state
The ADD state is not used for adding dives since adding dives
was made undoable. Therefore, rename it to EDIT state, since
that is what it is used for.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-07-03 14:30:46 -07:00
Berthold Stoeger
9424760eff cleanup: remove lost comment in profilewidget2.h
Clearly, this comment got lost in code reshuffling, as it comments
about ADD and PLAN mode, but is in front of picture declarations.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-07-03 14:30:46 -07:00
Berthold Stoeger
2a0ae4991b profile: remove EDIT_STATE from ProfileWidget2
This state is not used anywhere.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-07-03 14:30:46 -07:00
Dirk Hohndel
329fcf7fdc cleanup: update copyrights
That should have been done six months ago.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-07-03 14:28:37 -07:00
Dirk Hohndel
50ef42d580 cleanup: remove long obsolete code
We have stopped playing with beta versions many many years ago.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-07-03 14:28:37 -07:00
Dirk Hohndel
827e3f8ecc Latest translations from Transifex
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-07-02 09:36:37 -07:00
Dirk Hohndel
a7ae751105 Latest translations from Transifex
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-06-30 10:59:32 -07:00
Dirk Hohndel
d0b6e61fc1 update bundled mobile manual html
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-06-30 10:58:49 -07:00
Dirk Hohndel
7c93624c41 mobile: update version to 3.2.1
I should do this right after pushing a release for mobile.
2021-06-30 10:55:21 -07:00
Dirk Hohndel
32cec6a775 update README, ReleaseNotes, and supported dive computers for 5.0.2
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-06-30 10:53:31 -07:00
Dirk Hohndel
a529f90d46 Latest translations from Transifex
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-06-29 16:10:41 -07:00
Berthold Stoeger
48c2b4b1bd cleanup: remove unused item in ProfileWidget2's ItemPos
This is most likely an artifact from a long time ago.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-06-29 23:05:13 +02:00
Berthold Stoeger
080834c6f2 cleanup: remove dead code in ToolTipItem::refresh()
The code was downcasting the QGraphicsScene to ProfileWidget2,
but then didn't use the result. *shrug*

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-06-28 09:53:23 -07:00
Berthold Stoeger
248976bf11 cleanup: factor out duplicate axis-initialization code
The axes of the profile are setup when switching into
the "ProfileState" and also when the preferences are
changed. The same code existed twice for both cases.

Let's factor it out into a single function to avoid
future divergence and confusion.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-06-27 19:05:20 +02:00
Dirk Hohndel
9eb10af68f build-system: updates to processes
This is mostly for my own use, but I think it makes sense to have it in
the repo.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-06-07 08:25:31 -07:00
Dirk Hohndel
bf363c016b Update translation source strings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-06-07 08:23:48 -07:00
Berthold Stoeger
0b190243dd profile: remove internal event-copy (fix deleting/renaming events)
The DiveEventItem had an internal copy of the event. It passed
that copy to the undo-machinery, which of course didn't work.

Simply keep a pointer to the event. All changes to a dive no
pass via the undo-machinery, which causes a reload of the profile,
so this should be safe.

Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-06-05 11:29:00 -07:00
Berthold Stoeger
fd2862042b profile: pass axes and model to DiveEventItem on construction
Firstly, there is no point in supporting DiveEventItems without
model and axis. Secondly, this avoid pointless position-
recalculations.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-06-05 11:29:00 -07:00
Berthold Stoeger
c93fb83edf profile: pass event at construction time to DiveEventItem
There is no point in having a dive event without an event.
Let's pass the event at construction time to avoid having
to handle "invalid" events.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-06-05 11:29:00 -07:00
Mark Stiebel
e42fc1a1e9 desktop: add numerus translation for dive context menu
Add numerus translation lookup for the right-click context menu in the dive
list to show proper singular/plural text.

Fixes #3256

Signed-off-by: Mark Stiebel <mark@aretha.stiebel.me>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-06-04 09:35:16 -07:00
Dirk Hohndel
891805763e build-system: remove relative paths to icons
Asciidoc appears to insert './images' references when using the admonitionblock.
Clean that up in the post processing of the user manual for HTML.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-06-04 09:30:54 -07:00
Berthold Stoeger
4462ae5aee profile: remove unused function ProfileWidget2::getPrintMode()
The last user was removed in the previous commit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-06-04 08:45:32 -07:00