This should help us to move parsing that is not XML related to other
files, hopefully making the code cleaner.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Store cylinder.depth in XML files and in git storage.
This info is in fact the gas switch depth of a specific gas/cylinder
in the planner.
This change avoids the need of typing in a user specific depth value
again when replanning an existing planned dive.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Pass the planner state struct to the profile computation so it can use
deco_time and first ceiling to display VPM-B ceiling.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
For UI responsiveness, we need to be able to run the planner in the background. This needs the
planner state to be localized (and we need to pass a pointer around).
In order to not let too many lines overrun (and to save typing in the future)
I have renamed instances of struct deco_state to ds. Yes this should have gone
to a separate commit but I accidentally commit --amend'ed it.
Computing of planner variations is temporarily disabled.
Unlock the planner when returning early
So we don't deadlock in add dive and recreational mode (which
use the planner without actually planning).
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Add the capability to select the location name from a list, constructed
from the known dive sites in the logbook.
Fixes: #546
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Each preferences object owns its string members. In three cases, pointers
were copied instead of strings, leading to (in the best case) dangling
pointers if the user edited values:
1) In the GET_TXT macro in core/prefs-macros.h
2) In the PreferencesDialog::defaultsRequested() method
3) In main() of the mobile version
This patch fixes these issues, by using copy_string() or copy_prefs()
as appropriate.
The only reason that the old code didn't crash regularly is that the
default_prefs object was only used at startup and defaultsRequested()
is (at the moment?) dead code.
This patch also aligns the backslashes in core/pref.h and fixes a typo.
The declaration of copy_prefs() is moved to the core/prefs.h header.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Currently not mandatory in our code because we never include
prefs.h from a C file today but for the future this could avoid confusion.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Bool is the correct choice for this option.
int was used before because it was not clear to me how and if I can use
bool in this C file.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
In the old implementation there were two static C-style strings, filename
and path, which were initialized to NULL and filled on first call of
the function (i.e. singletons).
There is no sense in having two static variables indicating whether
this function was called previously. Moreover, there is no point
in remembering filename accross function calls, because it is not
used once path is set to a non-NULL value.
Therefore, make the filename variable non-static and calculate it only on
first invocation (as indicated by a NULL path). Moreover, free() the filename
variable after its use to fix a memory leak of the old code.
The windows code is slightly different in that the temporary filename is
not dynamically allocated.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This tries to remove subtle ownership issues. When copying preferences
structures, the default filename is copied. But the default preferences
struct simply takes a pointer to a global string which is free()d in main().
Now, this is not strictly a bug because the free()ing of preferences
resources is not implemented. Yet, let's try to make this consistent.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Boolean settings were declared in pref.h randomly as bools and shorts.
Since the code relied anyway on bool being well-defined and identical
on the C- and C++-sides, turn all of them into bools. They use less
space and express intent more clearly.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In general, the C++-side of the preferences code consistently uses
the bool data type for boolean settings. There are five exceptions,
which use short instead:
showPo2
showPn2
showPhe
saveUserIdLocal
displayInvalidDives
This patch attempts to make the code more consistent by turning
these into bools as well.
Tests showed that writing as short and reading as bool is handled
gracefully by the Qt variant code. Therefore, an upgrade should not
cause user-visible changes to their settings.
As a bonus, two extern declarations of the set_save_userid_local()
function, which is not defined anywhere, were removed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Make all char * pointers in pref.h const to make it clear that these
strings are not mutable. This meant adding a number of (void *) casts
in calls to free(). Apart from being the right thing to do, this commit
makes the code more consistent, as many of the strings in pref.h were
already const.
While touching core/qthelper.cpp turn three instances of (void*) into
(void *).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Commit d6c013f303 introduced a cast to avoid a signed/unsigned
comparison warning for all translation units that included
core/dive.h.
Commit 1f8506ce64 then changed the definition of duration_t from
unsigned to signed, inverting the effect of d6c013f303.
Thus, revert d6c013f303 to allow compilation with -Wall without
flooding.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Free a bunch of C-style strings before assigning newly copied strings.
One case was particularly buggy:
prefs.locale.use_system_language = copy_string(qPrintable(value));
Note that prefs.locale.use_system_language is a bool, which of course
always evaluates to true! Probably nobody noticed because a restart
is required when changing locale.
Moreover remove a few double-semicolons.
Stefan Fuchs points out that sometimes you get cylinder duplication when
you merge dives, particularly with a planned dive. For example, if we
had different manual pressures in the two different dives, the cylinders
will be kept separate.
But that also means that we don't want to plot the pressures from those
other cylinders that came from another dive and are now associated with
another dive computer.
Change the "seen" logic for the cylinder to ignore cylinders that are
only mentioned by other dive computers than the active one.
Reported-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
It's already used in core/gaspressures.c where it was declared
privately, and we'll have a new user in the profile code, so just
declare it in a proper header file like it should have been.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The "prev" cylinder can never be negative since commit 56c206d19f
("For more manual gas pressure details"), so remove stale code that
checks for a case that cannot happen any more.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Some BT devices support both, classical and LE, modes. Users could
choose either by prepending or removing "LE:" in the device address
field. After commit d23bd46a1b, the
device field is always disabled in Bluetooth mode.
Therefore, add a mode combo box to the Bluetooth device selection
dialog. In the default mode (auto), the old code path (based on
the Qt device flags) is used. The two other modes (force LE, force
classical) allow the user to force the preferred behavior.
This feature is meant as a stop-gap measure until a more refined
transport choice is implemented. Therefore, the value of the new
combo box is not saved in the settings, to avoid cluttering of
the preferences with soon to be obsolete entries.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The Windows auto-verbose + log file creation if starting
from a non-terminal has the problem that the print_version()
call is never made becase 'verbose' is updated programatically
in windows.c and not by the user (by passing -v).
To work around the issue:
- move the windows console creation call before *everything* else
- then immediatelly install the message handler
- then see if 'verbose' is set and explicitly call print_version()
print_version() now also has a flag (version_printed), to avoid
printing the version multiple times, if the user decided to add
an extra -v to the Desktop shortcut.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
If the user has not started Subsurface from a terminal
make sure that verbosity is enabled (verbose = 1), so that
the log files are populated with information useful for
debugging.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
When filling samples with values during DC import fill sticky values
like CNS, NDL, stoptime,... immediately into current sample.
Otherwise we will not fill the sticky values into the last sample
created.
Add two new sticky values: heartbeat and bearing
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Fixup the NDL value to '-1' at the very beginning of a dive.
Some dive computer report a NDL of 0 at the very beginning of a dive
and then only some 10 seconds later they report the correct value
like 240 min for the first time.
Translate this 0 at the beginning of a dive into our internal '-1'
for no info available.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Type duration_t changed from uint to int.
Default value of '-1' introduced for some of the values in struct sample:
NDL used -1 as default.
Bearing uses -1 as default (no bearing set).
Display pXX, EAD, END, density, MOD only if values are larger than 0.
In profile don't display data from two first and two last plot_data
entries in info box.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Currently, on Linux, after selecting a Bluetooth device the name of the
device is shown. On reopening the download dialog, on the other hand,
the address is shown. In the device selection dialog both are shown.
This patch changes the download dialog such that both, name and address,
are shown. The bulk of the patch introduces the name of the device in
the preferences and DCDeviceData. It has to be noted that DCDeviceData
is an encapsulation of the libdivecomputer device_data_t. Nevertheless,
the new Bluetooth-name field is, at the moment, not passed through to
libdivecomputer.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
On BLE connection timeout a weird error-message was shown, because
the controller was still in connecting state and no error string was
set. Therefore, handle the timeout case with a special case label.
Moreover, remove three unnecessary calls to disconnectFromDevice(),
which is called in the destructor of the controller anyway (verified
by looking at Qt source).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Commit 9771255919 introduces a compiler warning due to mismatched
pointer types. Fixed here.
Reported-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
I'm sure this bug has heen here forever, but the CNS clock is
not very relevant for most divers, and even some technical divers
do not care about this value.
However, doing long decompression dives, the value can easily
grow over 100%, and a lot further. For example, the OSTC computers
use 2 bytes to store the CNS value in the profile data, and I
have multiple dives in my logbook going way over 255%.
This all said. Just store the CNS value in an unsigned 16 bit.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Commit d15779a calculates final stop based on stoplevels[2], but if final stop
is 6m/20ft, we should use stoplevels[3]. This fixes it.
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Some messed up logic was producing negative deco_time values for some no-deco dives. The CVA wouldn't converge and unrealistic VPMB ceilings were displayed in the profile. This fixes it.
See #762
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
We calculate tts every 30s, not every sample. Consider that when determining
the time that the ceiling would have cleared if it's after the surfacing time.
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
This makes the calculations in profile.c a little simpler, especially now we
adopt consistent final ascent rate to determine deco_time since d15779a27
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
If we consider the actual time to ascend from the final stop when calculating
deco_time, then slowing the final ascent can lead to the final stop being
extended, which is completely nonsensical. For consistency with the original
VPMB implementation, we can't ignore the final ascent time completely, but if
we assume it is always the same (take default ascent rate of 9m/min) then
slower the final ascent won't lead to a longer final stop.
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
As it is not possible to delete dive sites from the logbook, we
need to make sure that we never save sites that are not tied to
any dive. With this change, unused site that are currently in
the logbook will also be removed, so it will also clear up
(wrong) historical data.
Supposed to fix#786
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
A change of the font_size in preferences ended up in the wrong
preferences group (the GeneralSettings group), appearing to the
user as a non-saved preference. Fix is simple. Just set the
the correct group before saving a change in font_size.
Fixes: #780
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Recognize Aladin as the Bluetooth name of the Scubapro Aladin Sport
Matrix. Note that the Scubapro Aladin H Matrix most likely also
identifies itself using this BT name. But it probably uses the same
BT protocol (i.e. the G2 protocol) and therefore this should not pose
a problem. Ultimately a common name should be found.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Remove unused variables o2time and breaktime or convert into boolean.
Never consider minimum gas switch time when switching to o2.
Reflect this behavior also in the UI.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
QMap::operator[] creates a new default constructed entry in the map
if no entry with the given key exists. While not problematic (since
typically nullptrs are inserted) this is usually not what you want
for read access.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Currently one has to explicitly use --win32console and/or
--win32log to enable a dedicated console (a console window
that opens next to the Subsurface window) or to enable file
logging on Win32.
This patch makes the following changes:
- removes the --win32* command line arguments
- removes the dedicated console window support
- if the app starts from a shortcut and not from a console, always
redirect stderr and stdout to _err & _out log files
- if the app starts from a console redirect stderr and stdout to that
console
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
1) Destroy QLowEnergyService objects in destructor of BLEObject.
2) Let BLE object take ownership of the controller so that the
latter can be destroyed in the destructor of the former. This
introduces a certain ownership subtlety, which could be solved by
allocating the controller object in the BLE object. But let's
first do the less intrusive thing.
3) Destroy the BLE object for two error conditions.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When planning a VPM-B dive, the "deco time" ends at surfacing, which is after
ascending after a full-minute deco stop is complete, after ceiling clears. We
should take this into account when calculating the ceiling outside of the
planner.
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
This corrects the issue where the displayed ceiling in the profile was
"broken" by the planner, especially for shorter and shallower dives.
Also fixes issue outside of planner where the deepest VPM-B ceiling was shown
too early, messing up the deco_time calculation.
VPM-B plans respond to change in O2% in gas as expected (in my testing)
Fixes: #630
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
If we consumed 0l/0bar in total from a cylinder there is no need to also
state that we consumed 0l/0bar during ascend.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Because now we are trying to open a URL as if it was a local file.
Again, the goal is to accelerated debugging if things go wrong.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is rather fragile code, and the capitalization of the error message
in libgit2 changed at some point. But commit 794739b4c0 ("strstr is a
case sensitive compare") didn't really fix the problem - as it broke
that same check for older libgit2 versions.
Instead use our new helper function to make it work with libgit2 old and
new.
Also, add some more error output so the next time we run into this it's
more obvious what broke and where.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
That's not a standard functions, so let's just build it. This is not
the most efficient way to write it, but it will do.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This string is substituted with the runtime increments derived of slight
variations in depth or bottom time in:
diveplannermodel.cpp:1058:
displayed_dive.notes = strdup(notes.replace("VARIATIONS", QString(buf)).toUtf8().data());
Translating it avoids substitution and we just get the translated
string.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Fixes minor interface inconsistency: After a failed download, the
error message was also shown on subsequent successful downloads.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Otherwise the following call to do_git_save will potentially have incorrect information
about the cache validity of the dives in the divelist.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Inexplicably, commit 8b7427c56d ("Move CloudStorage out of the widgets")
didn't just move the code but added a local member 'verbose' that hides
our global variable...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This became rather obvious with the change to immediately show errors.
The commit also fixes a small memory leak.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>