Dive site data was collected in "cur_dive_site", which was then
merged into an existing or a new dive site. But only the struct
dive_site pointed to by "cur_dive_site" and the taxonomy data
were freed, not the textual data such as name or description.
Therefore, split out the approrpriate free-ing from the
delete_dive_site() function and call that instead of a simple
free().
A similar situation occured for dives that would not be added
to the dive-table because they were deemed incomplete. Use
free_dive() here instead of a simple free() too.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
I incorrectly thought that 'ci_pointing_to_guiding_tissue' was the only
missing initialization, because that is the only one valgrind pointed at.
... that is, until I started looking at a few more dives, which showed
that there were other parts tht weren't initialized either, like
double tolerated_by_tissue[16];
double tissue_inertgas_saturation[16];
double crushing_onset_tension[16]; // total inert gas tension in the t* moment
so just make sure to clear the whole data structure, to avoid any random
behavior due to uninitialized deco state.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
In select_dive(), the selected dive would only be made the
current dive, if it wasn't previously selected. If multiple
dives were selected and the user clicked on one of them which
is not the current dive, then the current dive would be
deselected and thus not be the current dive anymore. The
only remaining dive would not be made the current dive,
because it was already selected. End result: null dive shown.
Therefore, always make the selected dive the current dive,
even if it is already selected.
Fixes#1792
Reported-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
On dive-download old dives are deselected and a new one is selected.
If no dives were downloaded, accordingly no dives were selected.
This deselect only dives if at least one dive was downloaded.
Fixes#1793
Reported-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
copy_dc_renumber() is an internal function to copy dive computers
and renumber the cylinders. Since only the structure was copied,
in the case of multi-dc dives, the merged dives shared the same
computer. If one of them was freed, use-after-free crashes would happen.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This was used to track whether we had selected the native BT mode in the
download dialog. But the information is redundant as we can tell from the
device name whether this is a BT/BLE download or not.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
process_imported_dives() might delete the currently selected
dives. This could lead to use-after-free problems. Therefore,
reset the currently selected dive to the last dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
On dive import, dives to be added may be merged into already
existing dives. In such a case, the dive to be added is deleted.
Before doing so, it must be removed from the trip is belongs to
to avoid corruption of the trip-list.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
On merging make a deep copy of the picture list, to avoid a use-after-free
crash after the orginal dive is deleted.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In commit 8c2383b495 dive merging was
changed to not modify the original dive. On import, dives were then
merged and the original deleted. The merge_weightsystem_info() was
not adapted accordingly (deep copy of string instead of pointer),
leading to a use-after-free crash.
Resolve this by doing a deep copy.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Ooops. Forgot to fix this before sent the patches, as this part doesn't
works on my travis builds.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
In windows builds, we don't build stripped subsurface binaries but
depend on previously built ones. For any reason, in regular windows
build libftdi is excluded, and library is not installed/built; on the
other side, in containerized build libftdi is included and we need to
include it in smtk.import build.
Setting pkg_config_library to QUIET works for both builds.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
mdbver.h is created on the fly by configure script and placed in our
$BUILDDIR/include, while the compiler search for it in
$SOURCEDIR/include. This could probably be achieved fine-tunning
configure script but ... well, it works.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Enable building of SmartTrak divelogs importer.
A new, lighter, tarball for mxe static libraries has been built, as it
seems impossible to build mdbtools with shared libraries (see mxe's
build matrix). The tarball doesn't include prebuilt mdbtools and we
build from source via build script.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
The DiveItem and TripItem classes were wrappers around dive * and
dive_trip * used to extract tabular data. With the rework of
DiveTripModel they lost all their state besides the pointer itself.
The usage was:
DiveItem item(d);
item.data(...);
This can now be simplified to the much more idiomatic
diveData(d, ...);
and analoguously for TripItem.
While adapting the data() function to be part of DiveTripModel, change
the
QVariant ret
switch(...) {
...
case ...:
ret = ...;
break;
...
}
return ret;
style to
switch(...) {
...
case ...:
return ...;
}
Not only is this shorter and easier to reason about, it generally also
improves the generated code. The compiler can directly construct the
return value in the buffer provided by the caller. Though modern
compilers start to be very good at avoiding unnecessary copies.
In total this cleanup results in a net-reduction of 190 lines of code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of calling free() on all dives, call free_dive() which also
frees additional allocated data, not only the dive struct.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There were two declaration of clear_table(), one in dive.h and one
in parse.h. The definition was in parse.c. Since the parser doesn't
even use the function, move the function and its declaration to
divelist.[ch] and remove the redundant declaration in dive.h.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This variable was only used in the divinglog_dive() function. There,
it was initialized right at the beginning and therefore there seems
to be no point in conserving its value across function-calls.
Make the variable local and remove the global version.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Does not solve any problem, but might help users that are confused
about the next/prev DC menu items, to select a different profile
for the currently selected dive. So, enable these menu items only
for dives where more than one DC is used.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Comits f427226b3b and 43c3885249 of the undo series introduced 2 calls
of autogroup_dives() without checking the autogroup global boolean.
This is a bug. An import from DC (for example) then triggers an
autogrouping, the divelist is autogrouped, and the UI button
is off.
This commit solves this. I've chosen for a guard in the autogroup_dives()
that now is a no-op when called when the user did not select autogrouping.
In additon, simplified the other calls to this function, as we do
not need to check before calling any more.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Instead of the weirdly named "information" and the inconsistent
"dive_list" use the logical "mainTab" and the camel-cased
"diveList", respectively.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The keeps track of different sub widgets needed by other parts
of the code, notably:
MainTab
PlannerDetails
PlannerSettingsWidget
ProfileWidget2
DivePlannerWidget
DiveListView
Access to these widgets was provided with accessor functions.
Now these functions were very weird: instead of simply returning
pointers that were stored in the class, they accessed a data
structure which describes the different application states.
But this data structure was "duck-typed", so there was an
implicit agreement at which position the pointers to the
widgets were put inside. The widgets were then down-cast by
the accessor functions. This might make sense if the individual
widgets could for some reason be replaced by other widgets
[dynamic plugins?], but even then it would be strange, as one
would expect to get a pointer to some base class.
Therefore, directly store the properly typed pointers to the
widgets and simply remove the accessor functions. Why bother?
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In the dive-site-edit widget, a copy of the current dive site was
used to store the old (pre-edit) data. This is not necessary, since
we can simply access the data in the original dive site. Thus,
replace the subobject by a simple pointer.
This is part of a series to replace dive-site uuids by pointers.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The displayed_dive_site object is used in the dive-site-edit widget
to store the old (before-edit) data. But it was also used to store
the GPS data when changed on the map or the input box. Very confusing.
Instead, use the text field as only authoritative source of the
GPS data.
This introduces a small behavioral change: when changing the text
of the GPS text field, update the list of dive sites at the same
position.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The dive-site-edit widget uses a copy of the to-be-edited site
to compare with old values. Generally, this seems overkill
(the original dive-site can be used for such a comparison).
But one place where it can't simply be removed is the taxonomy,
because the widget needs a place to store the unsaved data.
Change the code to use an explicit taxonomy structure instead
of the one provided in the copy. This should ultimately allow
removal of the latter.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The global object displayed_dive_site is used a a backing-store
by the dive-site-edit widget. All external accesses were removed,
therefore make the object local to the widget.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The global object "displayed_dive_site" is used to store the
old dive site data for the edit-dive-site widget. The fields
of the widget were initialized from this object in the show
event. Therefore the object was updated in numerous parts of
the code to make sure that it was up-to-date. Instead, move
the initialization of the object to the function that also
initiatlizes the fields. Call this function explicitly before
showing the widget.
This makes the data-fow distinctly easier to understand.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Remove a comment which is outdated in two ways:
1) The global variable "displayed_dive_site" was not used at all.
2) The location box cannot be used to rename dive sites.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
MainTab::refreshDisplayedDiveSite() was used after dive-site edit
to update the information of the location entry box. This should
always display the dive-site of the currently shown/edited dive,
therefore it makes no sense to use the displayed_dive_site here.
Simply use the dive site of displayed_dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The old code had a special case for dive-editing mode:
The dive site uuid of displayed_dive_site instead of displayed_dive
was used.
This makes no sense, because displayed_dive_site is only used by
the dive-site-edit widget, which firstly cannot be activated
during dive-edit and secondly doesn't change the dive site id
anyway.
Thus, use the dive site of the currently edited/displayed dive
in all cases.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When tabbing through the dive-info screen, a dive-master and a
dive-buddy would be added. The reason is that pressing tab would
be interpreted as a text-input. Disable this behavior by calling
setTabChangesFocus(true) in the TagWidget constructor.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The name seems crazy until you realize that FQ is 0x4651 which is the model
number of the i770R. And the six digits are the serial number of the device.
Still crazy, but at least now you understand WHY.
Thanks to Jef for decoding that.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If we update the device with a shortcut button, this is the reliable way to get
the information we need.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This makes no sense, but apparently we need to start a fresh scan in order to be able
to talk to a different BLE dive computer on the Mac.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Previously nothing was shown while we were trying to connect; now we show a busy
indication in the progress bar and ensure that the 'waiting to connect' text is
displayed. The progress bar switches back to showing actual progress once we have
connected and are downloading data.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
On macOS, we cannot connect to a BT/BLE device until we have scanned it. Right
now this just sits quietly and waits, which given how long this can take is
rather unsatisfying and might look like Subsurface is hung.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since we trigger a scan even without the dialog to pick the right
device, we need to remember all devices that we find.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead of only starting the scan when explicitly asked to do so in the BT
dialog, create the discovery agent when the download dialog opens, since on
macOS we cannot connect to a device without having scanned for it first.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>