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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
While Subsurface doesn't build on Windows, we shouldn't prevent people
from checking out the sources there...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Apparently, with Ubuntu 21.04 the qt5-default package doesn't
exist anymore. Removing it from the list of installed packages
makes things still work on a freshly installed system.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This takes an enum of units::LENGTH, therefore declare it as
such. Yes, this is kind of superfluous bike shedding, but since
we have a strongly typed language, let's use it.
On a side note, the enum should probably not be named with
all-caps.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This was only used by the child class DepthAxis,
where it was defined separately. An oversight?
In any case, remove the unused member.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When trying to build on Big Sur, the xcode command-line tools
install are installed in /Library/Developer/CommandLineTools/SDKs,
and as of Xcode 12.5, it does not include a 10.x version
of SDK.
This changes it to search in the location of the command-line tools SDK
for a 10.x version, and if it can't find a 10.x version it will
find an explicit 11.x version of the SDK to use because it is
conceivable that in the near future Apple will stop installing any
10.x SDK's as part of the command-line tool installer.
If the SDK can't be found, the build script will exit now instead
of continuing with an unset BASESDK version that causes a later failure.
Signed-off-by: Ryan Gardner <ryan.gardner@coxautoinc.com>