summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2019-08-24Desktop: fix crash on copy & pasteGravatar Berthold Stoeger
The constructor of PasteState was clearing an uninitialized weightsystem-table. Very silly. Initialize it instead. Fixes #2253 Reported-by: Stefan Fuchs <sfuchs@gmx.de> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-22Grantlee: generate vector of cylinder data on-demandGravatar Berthold Stoeger
Instead of generating cylinder data in the form of CylinderObjectHelper objects for every DiveObjectHelper, generate it only if needed. DiveObjectHelper is used extensively in the mobile interface, which doesn't use the cylinder data. Let's not generate unnecessary CylinderObjectHelpers in this case! Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-22Cleanup: turn CylinderObjectHelper into value typeGravatar Berthold Stoeger
CylinderObjectHelper is used for structured formatting of cylinder values in grantlee types. Instead of keeping a reference to a cylinder, turn it into a value type containing the formatted strings. This should be distinctly safer, as we don't risk having stale references flying around. Moreover, we don't have to use pointers but can use containers containing plain CylinderObjectHelper. Thus, no explicit memory management is needed, making the code distinctly easier to understand. Sadly, currently grantlee does not support Q_GADGET based Q_PROPERTY. Therefore a GRANTLEE_*_LOOKUP block has to be added. This can be removed in due course, as a patch to remedy this issue is in current grantlee master. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-22Cleanup: don't include dive.h in CylinderObjectHelper.hppGravatar Berthold Stoeger
This only needs the declaration of cylinder_t, which is found in equipment.h Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-20Replace table interpolation by two line fit for CNSGravatar Robert C. Helling
We used a table lookup for CNS equivalent times. Turns out the log of this table falls pretty much on a straight line for po2 <= 1.5bar. We now fit this tabel two two lines, one for <= 1.5 bar and one above. This four parameter fit has half the sum of errors squared than the five parameter fit using a fourth order polynomial. Fitting the log has the advantage that this never crosses 0, which would have the bad effect of resulting in negative CNS values as we divide by the table value. We don't adopt a maximum pO2 cut-off for the CNS calculation but rather live with the large values that the interpolation formula produces when extrapolating. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-08-19Update to latest libdivecomputerGravatar Linus Torvalds
Add support for Deepblu Cosmiq+ Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-19Fix the dive site XML savingGravatar Linus Torvalds
It turns out that the dive site saving was subtly but horribly buggy. To save the value of the dive site, it did show_utf8_blanked(b, t->value, " value='", "'/>\n", 1, anonymize); which looks sane on the face of it, but the problem is that it puts the final closing xml marker in the 'append this at the end' case. That means that if the value is empty, the value won't be saved, but neither will the closing tag. Resulting in an xml line that looks like this: <geo cat='3' origin='0' <geo cat='5' origin='0' value='Other name'/> where the first geo tag was saved without the ending marker. That then makes all the xml nesting entirely wrong, and the whole file fails to save. Now, the code around it does check that 't->value' is not NULL, but it doesn't check for a value that is empty or all spaces (which also will make 'show_utf8()' just skip it. Fix it by saving the end marker separately: show_utf8_blanked(b, t->value, " value='", "'", 1, anonymize); put_format(b, "/>\n"); so that the xml is valid even if the goe marker value wasn'r. Reported-by: Bob Barker <barkerb1965@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-18Desktop: show local git repos in recent filesGravatar Dirk Hohndel
But don't show our cloud storage entry (as that is already in the File menu, anyway). This is extremely useful because while you can manually enter a file name to save to (and therefore can use the 'magic' git repo syntax), on most OSs there is no way to enter that non-existing 'file name' (which is the git branch in square brackets) in the file open dialog. Fixes: #2236 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-18Add BLE name recognition for the Deepblu Cosmiq+Gravatar Linus Torvalds
It needs a newer version of libdivecomputer to actually download, but early very experimental code exists in the Subsurface-NG branch. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-13Mobile: fix bound check in DiveListModel::data()Gravatar Berthold Stoeger
Indexes go from 0 to count - 1. Thus, the comparison for invalid indexes has to read ">= count", not "> count". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-12DiveObjectHelper: warn if object is generated from the null pointerGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-12DiveObjectHelper: remove default argumentGravatar Berthold Stoeger
We don't support null-dives in DiveObjectHelper. Defaulting the dive parameter to NULL seems to send the wrong message. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-11Add CHANGELOG entry for mobile weight editingGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-11Mobile: use a default weight name when adding weight systemGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-11Mobile: support editing of dives with no weightsystemGravatar Berthold Stoeger
If a dive has no weightsystems, editing the weight system has to add a new entry in the table. Implement that. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-11Mobile: properly recognize single-weightsystem divesGravatar Berthold Stoeger
When removing the max-weightsystem restriction, the semantics of the DiveObjectHelper::singleWeightSystem() function changed: it now returned false for "no weightsystem". Change it back, to 0 or 1 weightsystems, because the mobile frontend uses this to check whether it can edit dive systems. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-11Add missing header files to macos.cGravatar Doug Junkins
Missing header files were causing errors opening cloud storage on launch on Mac OSX. Signed-off-by: Doug Junkins <junkins@foghead.com>
2019-08-10Fix potential crash when saved_git_id is NULLGravatar Dirk Hohndel
We have a safe strdup alternative. Let's just use it. Fixes #2220 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-10Android: fix potential crashGravatar Dirk Hohndel
I'm not sure about this one, as we test name at the start of the function and event->name shouldn't be NULL, but hey, we have the safe compare function, so let's use it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-10Mobile: catch null references in DownloadDCThreadGravatar Berthold Stoeger
There are reported crashes on Android that suggest a null "tables" attribute in DownloadDCThread. This should never happen, as the table() function connected to this attribute returns the address of a subobject. Thus, even if the original DownloadThread is null, this would not return a null pointer (the subobject is not at address 0). Catch these null-object accesses and write a warning message to the console. Hopefully, this will help is localizing the problem. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-10Mobile: update dive site model if dive sites are createdGravatar Berthold Stoeger
Always keep the dive site model up to date when adding dive sites. This hopefully avoids creation of invalid indexes followed by crashes. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-10Location model: treat invalid indexes gracefullyGravatar Berthold Stoeger
There have been crash reports in DiveSiteSortedModel::allSiteNames(). The only conceivable reason that this crashes is that the core knows about more sites than the model and therefore on mapToSource() we get an invalid index, which is translated to -1. Accessing the name of that dive site will crash. Handle such invalid indexes gracefully. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-10Core: unconditionally include stdio.h in libdivecomputer.hGravatar Berthold Stoeger
Header files should compile regardless of order of inclusion. Since libdivecomputer.h uses FILE unconditional include of stdio.h is the correct thing to do. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08iOS: address build errorGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-08Planner: pass dive to enough_gas()Gravatar Berthold Stoeger
Enough gas was checking the currently displayed dive instead of the dive to be planned. Not good in a multi-threaded context. Pass the actual dive instead. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08Planner: pass dive / cylinder pair to track_ascent_gas()Gravatar Berthold Stoeger
Pass the dive to be planned to track_ascent_gas and don't use the displayed_dive. For convenience, pass the cylinder-id, since the function can now access the cylinder of the dive by itself. This makes the callers less verbose. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08Planner: pass dive to analyze_gaslist()Gravatar Berthold Stoeger
Use the actual planned dive, not the displayed dive in analyze_gaslist(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08Planner: fix comment for create_dive_from_plan()Gravatar Berthold Stoeger
The function comment talks about overwriting displayed_dive, when in reality the function overwrites a passed in dive. Also fix a debug-call which dumped the displayed_dive, not the actual dive to stdout. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08Core: pass dive, cylinder-id to fill_default_cylinderGravatar Berthold Stoeger
The fill_default_cylinder() function calculated the MOD based on the currently displayed dive. This does not seem to make sense: - When importing dives, why would we care about the altitude and salinity of the currently displayed dive, possibly from a different trip. - The planner is supposed to be thread-safe and should not touch global variables. Of course this means that the importing-functions have to fill out altitude and salinity before creating the default cylinder, but this is their problem. For a freshly created dive they will get the default values, which still seems less random than the values from the displayed dive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08Planner: use planner's dive in interpolate_transition()Gravatar Berthold Stoeger
Instead of passing the global displayed_dive to calc_crushing_pressure(), use the dive the planner is working on. A small step in making the planner thread-safe. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08Parser: remove global stateGravatar Berthold Stoeger
The parser had global state in the form of a linear regression and the "plot_depth" variable. Collect that in the deco_state struct and pass it down the call-chain. Move out the code to update the regression data to not bother other callers of tissue_tolerance_calc(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-08-08Cleanup: remove unused function printdecotableGravatar Berthold Stoeger
It is unclear where this function has ever been used. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08Cleanup: make local functions in planner.c of static linkageGravatar Berthold Stoeger
A number of functions were not used outside of planner.c. Make them static. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08Cleanup: move planner/deco related declarations planner/deco.hGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08Cleanup: move file-related function declarations to file.hGravatar Berthold Stoeger
A number of architecture-dependent functions were declared in dive.h. Move them to file.h so that not all file-manipulating translation units have to include dive.h. This is a small step in avoiding mass-recompilation on every change to dive.h Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08Cleanup: move error reporting function declarations to errorhelper.hGravatar Berthold Stoeger
Move the declarations of the "report_error()" and "set_error_cb()" functions and the "verbose" variable to errorhelper.h. Thus, error-reporting translation units don't have to import the big dive.h header file. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08Cleanup: replace macro by inline function in gas-model.cGravatar Berthold Stoeger
Replace a macro calculating a degree-three polynomial by an inline function. Moreover, calculate the powers 1, 2 and 3 of the pressure inside the function. The compiler will be smart enough to optimize this to the same code. The only important thing is to write "x*x*x*coeff" instead of "coeff*x*x*x". The compiler can't optimize the latter because ... wonderful floating point semantics. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08Move the Suit text box from the Notes tab to the Equipment tabGravatar willemferguson
Sqash latest commit with previous one. Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2019-08-08Desktop user manual: dc managementGravatar willemferguson
The relevant text in the present manual is obsolete. Update the text dealing with dive profiles from several sive computers for one specific dive. One image is added. Deal with creating a new cylinder type. Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2019-08-08Desktop: display trip time on main-tabGravatar Berthold Stoeger
On the main tab, the trip time was not shown when switching to a trip. Implement showing of the trip date in a function, as the undo-code will also have to update the trip date in certain circumstances. Fixes #2207 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08Indicate negative cylider pressureGravatar Robert C. Helling
The planner can produce negative cylinder pressures when more gas is used than available. Let's color the pressure graph in a highly visible color to alert the user of the fact that current gas planning is insufficient. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-08-08Fix math in valueAtGravatar Robert C. Helling
DiveCartesianAxis::valueAt() is supposed to be the inverse of posAtValue(). This fixes the math such that inverted orientations are correctly taken care of. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-08-08Limit gas compressibility argument range to halfway sane valuesGravatar Linus Torvalds
The curve fitting for our gas compressibility was only done in the sane range of 0-500 bar, which is what a scuba cylinder can reasonably be expected to perhaps have. But the planner ends up happily using negative cylinder pressures when you run out of gas, and then the compressibility gives nonsensical results. That's clearly a planner bug, but the nonsensical gas compressibility values made it harder to see what could be wrong. So we just clamp the inpot range to the range we have verified against experimental data. If you try to get compressibility for negative pressures, you get the compressibility for an ideal and imaginary gas. And if you try to get compressibility for pressures over 500 bar, we'll just assume that it's 500 bar. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-04Cleanup: use clear_git_id() instead of setting saved_git_idGravatar Berthold Stoeger
For better encapsulation, use clear_git_id() in clear_dive_file_data() instead of setting saved_git_id directly. Thus, memory management of the saved_git_id value is encapsulated and can be modified more easily. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-04Coding style: add spaces in load-git.cGravatar Berthold Stoeger
Add spaces before and after multiplication and addition operators. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-04Git: Make parser reentrantGravatar Berthold Stoeger
The git parser was using a number of global static variables. Remove them by introducing a parser state, which is passed down to the call hierarchy. Advantages: 1) Removes global variables and makes the parser (mostly) reentrant. 2) More flexible - e.g. when parsing samples, the parser can now access the dive to check if the cylinder number is valid. 3) Less weak typing through "void *". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-04Cleanup: make functions in core/load-git.c localGravatar Berthold Stoeger
The function get_divemode() and git_tree_entry_blob() were not used outside of load-git.c. Make them of static linkage. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-02[smtk-import] fix mem leaks on site/location failure managementGravatar Salvador Cuñat
Signed-off-by: Salvador Cuñat <salvador,cunat@gmail.com>
2019-08-02[smtk-import] avoid infinite loop on index failureGravatar Salvador Cuñat
As Berthold points out, a failure to match the site or location index will result in an infinite loop with previous patch. With this one the loop will end after reading the last table row even if no idx is matched. But ... If we asume this situation is possible the retrieved data would be wrong, and ending the function without filling the site structure is mandatory too. Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2019-08-02fix site/location build issueGravatar Salvador Cuñat
We were assuming these tables were sorted with their indexes, but it happens to be false, under some circustances at least. Reported-by: Andreas Hagberg <scubasoft@gmail.com> Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>