Commit graph

757 commits

Author SHA1 Message Date
Miika Turkia
e18df84936 Hopefully fix Android build
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
b1b2638720 Move Cobalt and Divinglog DB parsing to parse-db.c
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
8be626d2c1 Move atoi_n to parse.c
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
b3605de93e Move Shearwater DB parsing into parse-db.c
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
568db03228 Move metric variable to parse.c
This is required when moving Shearwater DB parsing into parse-db.c

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
ddb9dba66c Move add_dive_site to parse.c
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
1c6e189c2b Move Suunto DB imports into parse-db.c
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
02c80a60b0 Refactore parse-xml.c into parse.c and parse-xml.c
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>
2017-11-27 13:42:10 -08:00
Stefan Fuchs
8d2bc595c7 Code cleanup: Move index declarations into for loop
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-27 22:40:16 +01:00
Stefan Fuchs
b17f1e2d30 Use MAX_SENSORS define everywhere
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-27 22:40:16 +01:00
Stefan Fuchs
8a92484b0c Add debug function dump_cylinders
This function can be used to dump print all cylinder data.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-27 22:40:16 +01:00
Stefan Fuchs
4e36b2509c Compile dump_tissues function only if needed based on define
Compile it only when DECO_CALC_DEBUG is defined.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-27 22:40:16 +01:00
Stefan Fuchs
46004c39e2 Store and load the planner related depth info of a cylinder in logfile
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>
2017-11-27 11:49:08 -08:00
Dirk Hohndel
dc67741e4f Update list of divecomputers supported in Subsurface-mobile
There was some whitespace change as well - this is straight from the
tool.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-11-26 22:20:52 -08:00
Stefan Fuchs
72318f2897 In strings start lower case in parenthesis
Start with lower case letter inside a parenthesis.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-25 15:41:28 -08:00
Stefan Fuchs
3d421584aa In planner.c remove unused variable o2break_done
Reported-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-25 15:40:04 -08:00
Robert C. Helling
088db5e12b Hand planner variables to profile
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>
2017-11-25 20:13:01 +01:00
Robert C. Helling
8e21a65653 Localize global planner state
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>
2017-11-25 20:13:01 +01:00
Robert C. Helling
a9ceecc2e3 Run variations calculation in background
but there are still side effects and thus it crashes.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-11-25 20:13:01 +01:00
Robert C. Helling
be6b50fce4 Add logic parentheses to make compiler happy
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-11-25 20:13:01 +01:00
Dirk Hohndel
e20e1aad0e Fix crash when dives have no dive site
get_dive_site_by_uuid() returns a NULL pointer in that case.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-11-25 08:19:47 -08:00
Jan Mulder
64704d6e5a mobile: autocomplete location names
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>
2017-11-25 08:13:42 -08:00
Berthold Stoeger
4fb01dd766 Fix ownership issues in preferences code
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>
2017-11-25 07:41:09 -08:00
Berthold Stoeger
cc5a56b275 Cleanup: remove unused extern declaration
Removes the extern declaration of edit_dive, which wasn't defined
anywhere.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-25 07:38:20 -08:00
Stefan Fuchs
f3c06279f1 Include stdbool.h also from prefs.h if included from C file
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>
2017-11-24 07:56:10 -08:00
Stefan Fuchs
bd88306722 Change prefs.show_units_table to bool
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>
2017-11-24 07:56:10 -08:00
Berthold Stoeger
04f38d61d7 Clean up system_default_filename()
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>
2017-11-22 19:22:29 +01:00
Berthold Stoeger
7a99d7e5c3 Copy default filename string when assigning to default preferences
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>
2017-11-22 19:22:14 +01:00
Berthold Stoeger
a15682ee76 Make handling of booleans consistent on the C-side of preferences
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>
2017-11-20 20:56:13 +01:00
Berthold Stoeger
dd8e4fae2a Make handling of booleans consistent on the C++-side of preferences
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>
2017-11-20 20:56:13 +01:00
Berthold Stoeger
e762fd2d41 Fix typo: successfull -> successful and succesfully -> successfully
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-20 10:01:15 +01:00
Jan Mulder
bde7caa621 Remove dead code
While investigating Qt 5.9.2 problems, I found this unused code.
Just remove it.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-11-19 12:20:43 -08:00
Berthold Stoeger
ebb8e1dc27 Trivial: fix indentation
Fix an obvious indentation bug where one line more than intended
was indented.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-19 00:21:45 +01:00
Berthold Stoeger
6ae16b87d0 Constify strings in pref.h
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>
2017-11-18 21:57:33 +01:00
Berthold Stoeger
1f651a7b83 Prevent annoying signed/unsigned comparison warning
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>
2017-11-18 21:50:43 +01:00
Berthold Stoeger
5ad6e168c6 Fix memory leaks in SettingsObjectWrapper.cpp
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.
2017-11-17 15:32:38 +01:00
Berthold Stoeger
9ec7aa7fd7 Fix typo: LENGHT -> LENGTH 2017-11-17 15:29:42 +01:00
Linus Torvalds
7fa5fcfa1d Don't show cylinder pressures for other dive computers
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>
2017-11-17 15:25:26 +01:00
Linus Torvalds
2e82a5d2ed Properly declare 'has_gaschange_event()' function
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>
2017-11-17 15:25:26 +01:00
Linus Torvalds
8136c2d78b Clean up confusing code in setup_gas_sensor_pressure()
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>
2017-11-17 15:25:26 +01:00
Berthold Stoeger
aca4a3a4fa Introduce mode field in Bluetooth device selection dialog
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>
2017-11-16 14:26:51 +01:00
Lubomir I. Ivanov
a8fbceac17 subsurface-startup: expose print_version() in the header
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>
2017-11-16 14:26:14 +01:00
Lubomir I. Ivanov
6161ca2083 windows.c: enable verbose level 1 for desktop usage
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>
2017-11-16 14:26:14 +01:00
Stefan Fuchs
72129289a8 During DC import reset cns, ndl, other values inbetween dives
Reset cns and heartbeat to 0
Reset ndl and bearing to -1

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-16 08:32:46 +01:00
Stefan Fuchs
85d00d1e7c For surface samples init ndl and compass bearing from prev sample
This avoids printing useless info to the XML file.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-16 08:32:46 +01:00
Stefan Fuchs
0895bccf49 libdivecomputer.c init sticky values for samples for current sample
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>
2017-11-16 08:32:46 +01:00
Stefan Fuchs
a8d4ff308d New fixup function fixup_dc_ndl
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>
2017-11-13 20:50:10 -08:00
Stefan Fuchs
adbc71f9da Init every struct sample with default values
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-13 20:50:10 -08:00
Stefan Fuchs
1f8506ce64 Display values in info box only if value is interesting
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>
2017-11-13 20:50:10 -08:00
Berthold Stoeger
de81effb25 Make Bluetooth naming consistent
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>
2017-11-13 20:48:17 -08:00
Berthold Stoeger
38b1b7d951 Better error message on BLE connection timeout
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>
2017-11-13 20:44:26 -08:00
Berthold Stoeger
b32251a5a8 Typo: modp02 -> modpO2
Fixes two function names, where O2 was written as 02.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-12 15:11:30 +01:00
Jan Mulder
f1437cfec7 Fix warning
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>
2017-11-10 10:31:19 +01:00
Dirk Hohndel
f16a488b89 Print version when run in verbose mode
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-11-09 16:21:46 -08:00
Dirk Hohndel
bcabe6ec9f Add details about key libraries when showing version
Also fixed a spelling error and apparently some whitespace issue.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-11-09 16:21:31 -08:00
Jan Mulder
9771255919 CNS can be higher than 255%
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>
2017-11-09 14:43:57 +01:00
Stefan Fuchs
a013e35ff4 Planner don't add minimum gas switch time more than once
Avoid adding the minimum gas switch time more than once even
if we skip some available deco gas.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-09 10:43:03 +01:00
Rick Walsh
13b909cf82 VPMB: calculate time of final ascent properly
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>
2017-11-08 15:22:32 +01:00
Rick Walsh
05b4113609 VPMB: time_clear_ceiling is only valid after time_deep_ceiling
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>
2017-11-08 15:22:32 +01:00
Rick Walsh
8e1ea8cd14 VPMB profile: remember deco_time when restoring deco_state
Otherwise the CVA won't iterate properly.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
2017-11-08 15:22:32 +01:00
Rick Walsh
b3b787db94 VPMB: final_tts may be calculated before final sample
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>
2017-11-08 15:22:32 +01:00
Rick Walsh
fe474ac266 VPMB profile: use deco_time rather bottom_time from planner
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>
2017-11-08 15:22:32 +01:00
Rick Walsh
e365cac54e VPMB in profile: deepest ceiling occurs just after bottom time
This lets us calculate deco_time for real dives closer to the planner value.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
2017-11-08 15:22:32 +01:00
Rick Walsh
4a727c64d9 VPMB: calculate deco_time assuming final ascent always takes the same time
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>
2017-11-08 15:22:32 +01:00
Rick Walsh
a06848c237 VPM-B: move bottom_time into deco_state
Removing ext variable from profile.c should facilitate future performance
gains

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
2017-11-08 15:22:32 +01:00
Jan Mulder
8d0361ff77 Do not save dive sites that are not used
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>
2017-11-08 14:07:36 +01:00
Jan Mulder
828f608b2b Save font_size in correct group
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>
2017-11-07 18:36:28 +01:00
Berthold Stoeger
cfc05f2a05 Add "Aladin" to the list of recognized BT names.
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>
2017-11-06 14:05:26 -08:00
Stefan Fuchs
aa5b017bea Fix typo which prevented correct translation of word "Density"
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-06 12:07:06 -08:00
Stefan Fuchs
ac25b238dd Disable o2 break option if last stop is not at 6m/20ft
Disable the possibility to plan o2 breaks of option
"last stop at 6m/20ft" is not set.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-04 14:51:02 +01:00
Stefan Fuchs
3ae0b5cbdd O2 breaks code enhancements and cleanup
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>
2017-11-04 14:51:02 +01:00
Berthold Stoeger
92ba4b9cc7 Replace QMap::operator[] with QMap::value()
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>
2017-11-04 14:26:21 +01:00
Lubomir I. Ivanov
0c74f7a2c8 win32: optimize the console and logging logic
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>
2017-11-03 07:49:11 -07:00
Berthold Stoeger
28299b0ebc Fix resource leaks in qt-ble.cpp
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>
2017-11-02 15:13:58 +01:00
Robert C. Helling
eafe19559a When O2 breaking, add segment with current mix not with next
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-10-31 16:33:32 -07:00
Robert C. Helling
c9c90afd3e Don't do the minimal gaschanging stops during O2 breakting
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-10-31 16:33:32 -07:00
Robert C. Helling
0f458023d9 Correct time bookkeeping when doing O2 breaks
These got mangled with previous changes to stop length determination.

Fixes #662

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-10-31 16:33:32 -07:00
Rick Walsh
68c2b10161 VPM-B ceiling: calculate deco_time similar to planned VPM-B dives
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>
2017-10-30 21:48:15 +01:00
Rick Walsh
f2535995f0 VPM-B ceiling outside of planner: over-estimate deco_time on first iteration
This means the iterations converge from an over-estimate, consistent with
planning VPM-B dives

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
2017-10-30 21:48:15 +01:00
Rick Walsh
eb62ced8a1 whitespace (planner.c)
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
2017-10-30 21:48:15 +01:00
Rick Walsh
04383e27e5 VPMB profile: use bottom_time to calculate deco_time in planner
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>
2017-10-30 21:48:15 +01:00
Stefan Fuchs
16f330e6c9 Planner remove unnecessary gas consumption info from notes
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>
2017-10-30 21:45:56 +01:00
Dirk Hohndel
38c4dfd45c Add a useful error message if we fail to connect to cloud server
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>
2017-10-30 12:27:29 -07:00
Dirk Hohndel
2878f32a22 Improve parsing of git error message
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>
2017-10-30 12:27:29 -07:00
Dirk Hohndel
1c42750cdf Add new helfer for strcasestr
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>
2017-10-30 12:27:29 -07:00
Dirk Hohndel
2d604ab2ff Mark missing translations
Reported-by: Pedro Neves <nevesdiver@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-29 20:00:53 +01:00
Stefan Fuchs
4e320cca5b Remove three obsolete preferences options for geocoding
These options are not used any longer/were never used and can be
removed to not confuse the users.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-29 11:07:52 -07:00
Salvador Cuñat
1095b78071 Planner: Do not translate VARIATIONS
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>
2017-10-28 08:19:18 +02:00
Berthold Stoeger
43a5cb3962 Clear error string when starting dive computer dowload.
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>
2017-10-26 20:45:25 +02:00
Dirk Hohndel
6852c3b039 git save: create a better commit message for initial commit
When we create an empty repo we should simply state that in the commit message.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-26 20:44:02 +02:00
Dirk Hohndel
1be4435175 git save: don't save the git_id if just creating empty repo
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>
2017-10-26 20:44:02 +02:00
Dirk Hohndel
bd54e94606 git save: remove redundant 'subsurface' from commit message
The user agent string already contains the (correctly capitalized) program name.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-26 20:44:02 +02:00
Dirk Hohndel
5269f8ce40 git storage: print the actual error
It seems silly to not show what git told us went wrong.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-26 20:44:02 +02:00
Dirk Hohndel
6f20d1a208 cloudstorage: handle invalid PIN correctly
If the server tells us that the PIN is invalid, we need to continue
to ask for a PIN.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-26 20:44:02 +02:00
Dirk Hohndel
95a8f951ba Remove bogus member that hides global variable
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>
2017-10-26 20:44:02 +02:00
Dirk Hohndel
405923ecfd Desktop UI: notify user if they need to enter a cloud PIN
This will need to be merged / cleaned up once the git storage fixes have
been merged.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-26 15:57:10 +02:00
Dirk Hohndel
3b92585a47 Don't show error if cloud credentials aren't set up
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>
2017-10-26 15:52:58 +02:00
Dirk Hohndel
eccd4b993a Set error callback helper
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-26 14:37:39 +02:00
Dirk Hohndel
6ec7d2d877 Move error reporting into its own source file
This doesn't really seem to belong in save_git.c.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-26 14:37:38 +02:00
Dirk Hohndel
27c49fe3ad Silence random warnings
None of these seem to point to actual issues, so let's quiet them.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-20 17:25:18 -04:00