aboutsummaryrefslogtreecommitdiffstats
path: root/core
AgeCommit message (Collapse)Author
2017-11-24Include stdbool.h also from prefs.h if included from C fileGravatar Stefan Fuchs
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-24Change prefs.show_units_table to boolGravatar Stefan Fuchs
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-22Clean up system_default_filename()Gravatar Berthold Stoeger
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-22Copy default filename string when assigning to default preferencesGravatar Berthold Stoeger
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-20Make handling of booleans consistent on the C-side of preferencesGravatar Berthold Stoeger
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-20Make handling of booleans consistent on the C++-side of preferencesGravatar Berthold Stoeger
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-20Fix typo: successfull -> successful and succesfully -> successfullyGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-19Remove dead codeGravatar Jan Mulder
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-19Trivial: fix indentationGravatar Berthold Stoeger
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-18Constify strings in pref.hGravatar Berthold Stoeger
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-18Prevent annoying signed/unsigned comparison warningGravatar Berthold Stoeger
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-17Fix memory leaks in SettingsObjectWrapper.cppGravatar Berthold Stoeger
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-17Fix typo: LENGHT -> LENGTHGravatar Berthold Stoeger
2017-11-17Don't show cylinder pressures for other dive computersGravatar Linus Torvalds
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-17Properly declare 'has_gaschange_event()' functionGravatar Linus Torvalds
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-17Clean up confusing code in setup_gas_sensor_pressure()Gravatar Linus Torvalds
The "prev" cylinder can never be negative since commit 56c206d19fba ("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-16Introduce mode field in Bluetooth device selection dialogGravatar Berthold Stoeger
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 d23bd46a1be2dfb25293639abcf06b5b4d4b94df, 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-16subsurface-startup: expose print_version() in the headerGravatar Lubomir I. Ivanov
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-16windows.c: enable verbose level 1 for desktop usageGravatar Lubomir I. Ivanov
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-16During DC import reset cns, ndl, other values inbetween divesGravatar Stefan Fuchs
Reset cns and heartbeat to 0 Reset ndl and bearing to -1 Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-16For surface samples init ndl and compass bearing from prev sampleGravatar Stefan Fuchs
This avoids printing useless info to the XML file. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-16libdivecomputer.c init sticky values for samples for current sampleGravatar Stefan Fuchs
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-13New fixup function fixup_dc_ndlGravatar Stefan Fuchs
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-13Init every struct sample with default valuesGravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-13Display values in info box only if value is interestingGravatar Stefan Fuchs
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-13Make Bluetooth naming consistentGravatar Berthold Stoeger
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-13Better error message on BLE connection timeoutGravatar Berthold Stoeger
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-12Typo: modp02 -> modpO2Gravatar Berthold Stoeger
Fixes two function names, where O2 was written as 02. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-10Fix warningGravatar Jan Mulder
Commit 97712559192ca82d 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-09Print version when run in verbose modeGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-11-09Add details about key libraries when showing versionGravatar Dirk Hohndel
Also fixed a spelling error and apparently some whitespace issue. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-11-09CNS can be higher than 255%Gravatar Jan Mulder
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-09Planner don't add minimum gas switch time more than onceGravatar Stefan Fuchs
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-08VPMB: calculate time of final ascent properlyGravatar Rick Walsh
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-08VPMB: time_clear_ceiling is only valid after time_deep_ceilingGravatar Rick Walsh
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-08VPMB profile: remember deco_time when restoring deco_stateGravatar Rick Walsh
Otherwise the CVA won't iterate properly. Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
2017-11-08VPMB: final_tts may be calculated before final sampleGravatar Rick Walsh
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-08VPMB profile: use deco_time rather bottom_time from plannerGravatar Rick Walsh
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-08VPMB in profile: deepest ceiling occurs just after bottom timeGravatar Rick Walsh
This lets us calculate deco_time for real dives closer to the planner value. Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
2017-11-08VPMB: calculate deco_time assuming final ascent always takes the same timeGravatar Rick Walsh
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-08VPM-B: move bottom_time into deco_stateGravatar Rick Walsh
Removing ext variable from profile.c should facilitate future performance gains Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
2017-11-08Do not save dive sites that are not usedGravatar Jan Mulder
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-07Save font_size in correct groupGravatar Jan Mulder
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-06Add "Aladin" to the list of recognized BT names.Gravatar Berthold Stoeger
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-06Fix typo which prevented correct translation of word "Density"Gravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-04Disable o2 break option if last stop is not at 6m/20ftGravatar Stefan Fuchs
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-04O2 breaks code enhancements and cleanupGravatar Stefan Fuchs
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-04Replace QMap::operator[] with QMap::value()Gravatar Berthold Stoeger
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-03win32: optimize the console and logging logicGravatar Lubomir I. Ivanov
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-02Fix resource leaks in qt-ble.cppGravatar Berthold Stoeger
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>