aboutsummaryrefslogtreecommitdiffstats
path: root/core
AgeCommit message (Collapse)Author
2021-03-31core: initialize dive selection after resetting the dataGravatar Berthold Stoeger
The dive selection was initialized during data-reset. However, this emitted a signal before all data-reset routines were run. Ultimately, this led to access-after-free in the statistics code. Instead, move the select_newest_visible_dive() signal from the divelist-model to the process_loaded_dives() function. There is no point in initializing the selection if the dive data is cleared after all. This change broke closing of the log, because the UI-selection was not reset. Therefore, when clearing the data, clear the selection before proceeding with clearing. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-03-24planner: fix deco calculationGravatar Berthold Stoeger
In 9bfc6d252, testing of the planner was changed to use the planner_ds parameter instead of a global variable. Unfortunately, two conditionals were inverted, leading to an erroneous ceiling calculation when in the planner. Restore the proper conditions. Moreover, instead of testing the planner_ds parameter, use the already existing in_planner flag, which is derived from said parameter. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-03-12Use PSCR gas when computing O2 toxicityGravatar Robert C. Helling
Both the calculations for CNS and OTU did not take into account the pO2 drop when using a PSCR. Furthermore, there was some unit confusion due to not using internal units. Reported-by: arosl Signed-off-by: Robert C. Helling <helling@atdotde.de>
2021-03-12Use QtBluetooth enums from their namespaceGravatar Andreas Buhr
For increased type safety, some enums have been changed to scoped enums in Qt 6.2, see https://codereview.qt-project.org/c/qt/qtconnectivity/+/337069 https://codereview.qt-project.org/c/qt/qtconnectivity/+/336678 This patch adapts subsurface to this change. Since C++11, enums inject their symbols in both their own and their parent namespace, so this patch can be merged right now. Signed-off-by: Andreas Buhr <andreas.buhr@qt.io>
2021-03-08parser: initialize picture variableGravatar Berthold Stoeger
When parsing "event 123" (?) a picture is added, without initializing the picture structure. Thus, a picture with a random gps location is added. Use the "empty_picture" initializer to avoid that. Fixes a Coverity warning. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-03-01Max ceiling precisionGravatar Robert C. Helling
We used to round the ceilings for the individual tissues with %.1f but the maximal (and thus effective) ceiling only with %.0f. This makes no sense or be rounded up (to the conservative side). This commit shows also the maximal ceiling with higher accuracy. Reported-by: Peter Hübner Signed-off-by: Robert C. Helling <helling@atdotde.de>
2021-02-26Get O2 right in bailout modeGravatar Robert C. Helling
When doing OC bailout from a CCR dive, there could still be pO2 sensor readings but those are not valid. This fixes a problem noticed by Justin Ashworth. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2021-02-26Fix pO2 for CCR at shallow depthsGravatar Robert C. Helling
Even when diving a CCR, the pO2 cannot exceed ambient pressure. This only makes a difference at shallow depths. Fix this in the calculation of OTUs and CNS. This affects some tests that now have slightly different CNS and OTU values. Suggested-by: Justin Ashworth Signed-off-by: Robert C. Helling <helling@atdotde.de>
2021-02-26Planner: Depth dependent setpoint changes in CCR modeGravatar Robert C. Helling
We had a user request to allow for setpoint changes at certain depths for CCR deco. You can now enter a cylinder with name like "SP 1.4" ('S' and 'P' and ' ' and a float) with a switch depth and that cylinder is interpreted as a depth dependent setpoint switch. This user interface is a hack. But I believe that such setpoint changes are similar enough to gas switches during deco and should thus be handled in a simiar manner. I would be happy to hear ideas how this could be made less easter eggish. Suggested-by: Justin Ashworth Signed-off-by: Robert C. Helling <helling@atdotde.de>
2021-02-17desktop: fold ApplicationState into MainWindowGravatar Berthold Stoeger
The application state is a desktop-only thing. The mobile UI also has its application state, but that is something completely different. The last remaining user of the application state was to flag whether the planner is active. Since this has all been unglobalized, the ApplicationState structure can be moved from core to the desktop UI. And there it can be made local to the MainWindow class. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-17planner: pass in_planner down to TemplateLayoutGravatar Berthold Stoeger
The TemplateLayout prints different dives depending on whether the planner is active. Instead of accessing a global variable, pass the status down from the MainWindow. That's all quite convoluted, since there are multiple layers involved. On the positive side, the in_planner() function has now no users an can be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-17planner: pass in_planner argument to decoMode()Gravatar Berthold Stoeger
To remove reliance on global state, pass an "in_planner" argument to decoMode(). Thus, calls to in_planner() can be removed. This is a more-or-less automated change. Ultimately it would probably be better to pass the current deco-mode to the affected functions instead of calling decoMode() with an in_planner parameter. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-17planner: pass in_planner argument to clear_deco()Gravatar Berthold Stoeger
To remove reliance on global state, pass an "in_planner" argument to clear_deco(). Thus, calls to in_planner() can be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-17planner: pass in_planner argument to vpmb_next_gradient()Gravatar Berthold Stoeger
To remove reliance on global state, pass an "in_planner" argument to vpmb_next_gradient(). Thus, calls to in_planner() can be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-17planner: pass in_planner argument to add_segment()Gravatar Berthold Stoeger
To remove reliance on global state, pass an "in_planner" argument to add_segment(). Thus, calls to in_planner() can be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-17planner: remove print_mode parameter from calculate_deco_information()Gravatar Berthold Stoeger
Only 'false' was ever passed as value. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-10desktop: cache photo and geo iconsGravatar Berthold Stoeger
The icons shown in the dive list were rendered for every single access. Render them only once. This supposes that the defaultIconMetrics structure does not change once the icons are rendered! Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-06desktop: remove the view-stateGravatar Berthold Stoeger
There was the "application state", which decided what to show in the "quadrants" and the "view state" which decided which quadrant to show. These interacted in a hard-to-grasp way. The "view state" is used to show the map or dive list in full screen. I simply couldn't get these two orthogonal states to interact properly. Moreover the thing was buggy: If a quadrant was hidden, the user could still show it, by dragging from the side of the window, at least under KDE. To solve these woes, merge the two states into a single application state. If the widget of a quadrant is set to null, don't show it. So the four "view states" are now "application states" where three of the four quadrants are not shown. This also changes the memory management of the widgets: widgets that are not shown are now removed from the QSplitter objects. This makes it possible that the same widget is shown in *different* quadrants. While writing this, I stumbled upon a Qt bug, which is known since 2014: https://forum.qt.io/topic/43176/qsplitter-sizes-return-0 When restoring the quadrant sizes there was a test whether the quadrant size is 0. If that was the case, a default size was set. This seems not to work if the widgets were recently added. Since this test now always fails, make the quadrants non-collapsible and thus guarantee that 0 is never saved as a size. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-28core/BT: fix duplicate entries in BT detectionGravatar Dirk Hohndel
Somehow three identical lines snuck into commit 0a4e37ee8b ("core/BT: simplify detection of bluetooth names"). Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-23core/BT: simplify detection of bluetooth namesGravatar Dirk Hohndel
Instead of that super long if-else if chain, have something more structured using a table for the common case of prefix based names. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-23core/BT: improve BT name detection for Pelagic dive computersGravatar Dirk Hohndel
It would be so much nicer if we could just let libdivecomputer do this, but the filter function there doesn't quite do things the way we need them to be. Which is why we have our own function here. This is a small attempt to rationalize the code that we have to make it easier to maintain. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-23mobile/debugging: copy GPS fixes to clipboardGravatar Dirk Hohndel
The goal is to enable a user experiencing crashes when applying GPS data to their dive log to make all necessary data available to the developers. Hopefully the clipboard is large enough to hold all the data. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-20cleanup: constify create_plot_info_new()Gravatar Berthold Stoeger
This only read accesses the dive and constructs a plot-info structure. Make the dive parameter const. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20cleanup: constify populate_pressure_information()Gravatar Berthold Stoeger
This has only read access on the dive. Make the parameter const. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20cleanup: constify init_decompression()Gravatar Berthold Stoeger
This function initializes decompression data from a dive. The dive is not modified, therefore make it const. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-19mobile/UI: remember the system default font sizeGravatar Dirk Hohndel
We need to do this before the preferences are loaded, or the system default size is lost. Given that our other sizes are all relative to this value, that would be a problem. With this we can now ensure that we always have the right font size for smaller, regular, and larger theme settings. Also removes some obsolete commented out code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-19cleanup: create separate UI entry points for desktop and mobileGravatar Dirk Hohndel
This doesn't really change anything, but makes the code easier to read. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-19mobile: add GF fields for ceiling calculationGravatar Doug Junkins
Adds fields to the advanced preferences page to modify GFLow and GFHigh for the Buhlmann decompression model for calculating ceilings. Updated preferences code to set the Buhlmann parameters in core/deco.c when the GF prefs are updated. Signed-off-by: Doug Junkins <douglas.junkins@gmail.com>
2021-01-13core/bluetooth: make device discovery less noisyGravatar Dirk Hohndel
This mainly combines reasonably redundant text to make the output easier to read. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-13mobile/GPS: fix two errors in the GPS handlingGravatar Dirk Hohndel
First, the time zone adjustment was wrong - this as written could only ever have worked in UTC or by pure chance. Second, the order of alerting the UI of the availability of a GPS fix was also incorrect creating a race between the UI and our data structures. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-11undo: set dive mode to CCR in undo command, not profile codeGravatar Berthold Stoeger
When setting a CCR setpoint, the profile code(!) would turn the dive into a CCR dive. Not only should the display layer not alter dives, this also means that the action is not undoable. Move that to the appropriate undo command, where it makes more sense, but obviously also makes things more complicated. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-11undo: remove invalidate_dive_cache() call from make_first_dc()Gravatar Berthold Stoeger
The make_first_dc() function clones a dive with a certain dive computer moved to the front. This is used by the MoveDiveComputerToFront undo command. make_first_dc() calls invalidate_dive(). However, the undo command does that by itself on every undo/redo. Thus, remove the call in make_first_dc(). Aside from consistency, the goal is to move invalidate_dive() to command/* so that we can be more aggressive about the whole topic: Store only "const dive *" pointers and thus force any writing access to explicitly invalidate the dive cache. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10mobile: enable deco information calculation on mobileGravatar Dirk Hohndel
This simply allows us to calculate the information, it doesn't do anything to actually display it, yet. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-10profile: pass dive to DiveHandlerGravatar Berthold Stoeger
The DiveHandler shows a context menu where a cylinder can be chosen. This indirectly accesses the global displayed_dive variable. Remove this in a step to make the profile reentrant. The code was quite ominous: instead of simply generating the list of cylinders, a global model was reset and then accessed with Qt's cumbersome model/view API. All this trampling over global state can be removed by simply making the function that generates the list globally accessible. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10profile: pass dive to RulerItemGravatar Berthold Stoeger
Instead of accessing the global displayed_dive variable in RulerItem, pass the dive. This is a step in making the profile reentrant. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10profile: pass dive to ToolTipItem::refresh()Gravatar Berthold Stoeger
Don't access the global displayed_dive variable in a step to make the profile reentrant. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10profile: pass dive to plot function of profile-itemsGravatar Berthold Stoeger
Instead of accessing the global displayed_dive variable, pass the dive to the various profile items. This is a step in making the profile code reentrant. This removes the last user of the displayed_dc macro, which can now be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10profile: pass dive to EventItemGravatar Berthold Stoeger
Don't access the global displayed_dive variable in an effort to make the profile reentrant. Note that this still accesses the global dc_number variable, which will likely have to be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10profile: move adding of ceiling-violation-eventGravatar Berthold Stoeger
The profile item that shows the ceilings adds a warning event if the ceiling is violated. This is very unfortunate. Improve this situation by adding the event up to the function that calculates the ceiling. This is still not how it should be - the display layer should not modify the dive that it displays. To make this clear, add a comment that details that this is a contract between planner and display layer: The planner uses a dive that can be trampled upon by the profile. Still, this should be solved differently. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10profile: use a parameter to determine planner stateGravatar Berthold Stoeger
The in_planner() function is incompatible with a reentrant profile, since it accesses a global variable. In create_plot_info_new() it is essentially redundant, because there is a planner_ds (ds = deco_state) parameter that is used only when in the planner. Therefore use that as the in_planner indicator: when non-null, the profile is showing a planned dive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10cleanup: make calculate_deco_information() of static linkageGravatar Berthold Stoeger
This function was not used outside of profile.c Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10btdiscovery - Add second matcher for Ratio iX3MGravatar Damian Zaremba
New (late 2020) iX3M hardware (refered to as 'iX3m with Sequared Buttons' in the Ratio support section) appears to identify as iX5M, both in the Bluetooth name and reported revision e.g. $ ./ratio-toolbox-x86_64.AppImage info | head -n2 Model: Ratio® iX5M GPS TECH+ Firmware version: 4.1.26/016 (English) Add a second Bluetooth name matcher for this variation, returning the same (generic) model as is currently used. Signed-off-by: Damian Zaremba <damian@damianzaremba.co.uk>
2021-01-06preferences: remove pointless memberGravatar Dirk Hohndel
This could never have worked the way it was used. Some whitespace fixes snuck into this commit. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-03desktop: add statistics widget dummy and application stateGravatar Berthold Stoeger
Add a new "statistics" application state. In the statistics state show the statistics widget and the filter in the top quadrants. The idea is to allow filtering and doing statistics at the same time. Sadly, we can't use the filter-widget in different quadrants, because Qt's ownership model is completely broken / inflexible. It does not support a widget having different parents and thus a widget can only belong to one QStackedWidget. Hiding the map in the statistics view is quite hacky: Since the view of the quadrants is not determined by the "ApplicationState", we have to restore the original quadrant visibility when exiting the stats mode. Therefore, set the original visibility-state when changing application state. The MainWindow-quadrant code really needs to be rewritten! Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02mobile: turn GpsLocation into a regular singleton constructGravatar Dirk Hohndel
Simply move the initialization of the logging function into its own method and call that in the QMLManager constructor. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-02cleanup: move pref related structs and functions to pref.cGravatar Berthold Stoeger
These were declared in pref.h and defined in subsurfacestartup.c. pref.c didn't even exist. Create it and move preferences-related structs and functions there. setup_system_prefs() is left in subsurfacestartup.c, since it works with environment variables. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02cleanup: move definition of get_units() to core/unit.cGravatar Berthold Stoeger
The function is declared in core/unit.h, therefore it seems logical to define it in the corresponding source file. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02cleanup: remove support for PASCAL in get_pressure_units()Gravatar Berthold Stoeger
The user preferences can never end up with PASCAL pressure units. The only place that uses these units is the XML parser. Therefore, remove the PASCAL case in get_pressure_units(). This will remove an unused translation string. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02cleanup: don't save PASCAL pressure units to gitGravatar Berthold Stoeger
The way I understand, the PASCAL pressure unit is used to parse obscure dive logs. However, there is no support in the UI for using Pa as pressure unit. Therefore remove reading / writing this unit to git divelogs. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01cleanup: ensure DiveFilter is consistent when createdGravatar Dirk Hohndel
Otherwise we might access an uninitialized member. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>