This was the umpteenth inefficient reinvention of a trivial
map. Replace by a hash-map (std::unordered_map). Might just
as well use a balanced binary tree or a sorted array. In the
end, it probably doesn't matter at all.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
uemis_get_divenr() returns maxdiveid and passes mindiveid as a
global variable.
Make this more reasonable by returning a min, max pair.
The way mindiveid is an unsigned int and then reinterpreted as
int is very sketchy. This commit attempts to not change that
behavior.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is only initialized and used in one loop. Very mysterious
why this should be a global variable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This global variable is used in two function independently of
each other. I don't see how there should be transport of this
value from one function to the other. Ominous.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
uemis_get_answer() would put the raw response into a global variable.
This could be anywhere in the call stack and thus you never knew
when the existing buffer was removed under your feet.
Instead, return the buffer explicitly from uemis_get_answer().
I'm nit perfectly happy about the new interface: an error is
indicated by an empty buffer, which is awkward to test for.
If an empty buffer turns out to be a valid response, this
should be replaced by an std::optional<> or std::expected<>.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The string code of uemis-downloader.cpp was broken in more ways
than can be listed here. Notably, it brazenly refused to free any
memory allocated for the parameters buffer.
Using std::string and std::string_view should plug all those
memory holes. That made it necessary to do some major refactoring.
This was done blind and therefore will break.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
newmax was an integer variable kept as a string. Very ominous.
Moreover, memory management seems to be broken:
1) The string is never freed.
2) The string is passed as value from do_uemis_import() to
get_matching_dives(), which passes it as reference to
process_raw_buffer(), which may reallocate it, which means
that do_uemis_import() now possesses a pointer to a free()d
string.
Simplify all that by making newmax an integer variable and
passing it as a reference from do_uemis_import() to
get_matching_dives().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There were a number of fprintf()s that escaped the conversion
to report_info(), because they used "debugfile" instead of
"stderr" as target. However, debugfile was just #defined to
be stderr, so we might just use report_info() for consistency.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The uemis code is wild. It simply doesn't deallocate memory
and uses global variables. To get this under control, create
a "struct uemis" and make the functions exported by "uemis.h"
members of "struct uemis". Thus, we don't have to carry around
a parameter for the state of the importing process.
Turn a linked list of "helper" structures (one per imported dive)
into a std::unordered_map, to fix leaking of the helper structures.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This was very obscure: the function that parses into a struct
dive was passed a void-pointer instead of a struct dive-pointer.
Why? Just pass the correct type.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The SHA1() helper function was only used when calculating a
SHA1 hash and taking the first four bytes of it as uint32.
Make that explicit by renaming the function into SHA1_uint32()
and directly returning an uint32_t.
Note that the usage in cochran.cpp is sketchy: it generates
a four-byte hash out of two-byte data. Why!?
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The strtod_flags() function allowed for fine control of how to
parse strings. However, only two different modes were actually
used: ascii mode ("C" locale) and permissive mode (accept ","
and "." as decimal separator).
The former had already its own function name (ascii_strtod).
Make the latter a separatge function as well (permissive_strtod)
and remove all the flags rigmarole.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Owing to bitrot, this union only contained a float and therefore
is pointless. Let's remove it.
That makes the function name "integer_or_float()" non-sensical.
Call it "parse_float()" instead.
Moreover, change the output-arguments of "parse_float()" from
pointers to references, as null-pointers are not supported.
Finally, remove the "errno" check after "ascii_strtod()". As far as
I can tell, errno is not set in "ascii_strtod()" and using a global
variable for error-reporting it is an incredibly silly interface
anyway.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Some improvements:
- for constraints where the condition is applied to any one of a list of
items, show the condition as 'any X';
- when filtering for tags, do not include divemode as a 'tag' - this is
hard to impossible for users to understand, and we do have a dedicated
condition for the dive mode.
Signed-off-by: Michael Keller <github@ike.ch>
Fix loading of the negation of filter conditions. Unlike other
conditions that are persisted as `<key>="<value>"`, this is persisted
to git as `negate`.
This fix remediates this for all cases where the condition has already
been saved to the cloud storage.
Saving to XML takes a different approach and indicates negated
conditions with `negate="1"`, making it identical to all other
attributes. The question is if this approach should be implemented in
addition to the above fix, in order to unify the storage format.
Fixes#4246.
Signed-off-by: Michael Keller <github@ike.ch>
Fix an issue introduced in #4148.
Essentially the refactoring missed the fact that in the imperial system
tank size is tracked as the free gas volume, but in the metric system
(which is the one used in most of Subsurface's calculations) tank size
is tracked as water capacity.
So when updating a tank template tracking imperial measurements, the
given (metric) volume in l has to be multiplied by the working pressure,
and vice versa.
This also combines all the logic dealing with `tank_info` data in one
place, hopefully making it less likely that this will be broken by
inconsistencies in the future.
Fixes#4239.
Signed-off-by: Michael Keller <github@ike.ch>
- show the correct gasmix in the profile;
- make gases available for gas switches in the profile after they have
been added;
- persist gas changes;
- add air as a default gas when adding a dive.
This still has problems when undoing a gas switch - instead of
completely removing the gas switch it is just moved to the next point in the
profile.
Signed-off-by: Michael Keller <github@ike.ch>
The last use of these functions was removed in ae299d5e66.
And that's a good thing, because snprintf-style interfaces
make zero sense in times of variable-length character
encodings.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
A long standing issue: the dives_to_add, etc. tables need to be
manually freed. This kind of problem wouldn't arise with proper
C++ data structures.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
- standardise the naming;
- use it consistently;
- apply the 'samples < 50' only when putting manually added dives into
edit mode - everywhere else manually added dives should be treated as
such;
- do not show a warning before editing a manually added dive in planner.
Signed-off-by: Michael Keller <github@ike.ch>
Error introduced in da7ea17b66: the INFO() and ERROR() macros
pass stdout instead of the format string as first parameter
to report_error(). Ooooops. How did this ever pass the
compile tests!?
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
46cf2fc086 fixed a bug where clearing of a divelog, such as the one
used for import, would erase dives in the global(!) divelog.
However, the new code used the function clear_dive_table(), which
only cleared the table without unregistering the dives. In particular,
the dives were not removed from the trips, which means that the trips
were not free()d.
This reinstates the old code, but now passes a divelog paremeter
to delete_single_dive() instead of accessing the global divelog.
Moreover, delete dives from the back to avoid unnecessary
copying.
An alternative and definitely simpler solution might be to just
add a "clear_trip_table()" after "clear_dive_table()".
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Currently editing of planned dives that have been merged with actual
(logged) dives only works if the 'Planned dive' divecomputer is the
first divecomputer, and this divecomputer is selected when clicking
'Edit planned dive'. In other cases the profile of the first
divecomputer is overlaid with the profile of the planned dive, and the
first divecomputer's profile is overwritten when saving the dive plan.
Fix this problem.
Triggered by @SeppoTakalo's comment (https://github.com/subsurface/subsurface/issues/1913#issuecomment-2075562119): Users don't like that planned dives show up as their own entries in the dive list, so being able to merge them with the actual dive after it has been executed is a good feature - but this wasn't working well until now.
Signed-off-by: Michael Keller <github@ike.ch>
Convert some C-style strings in uemis-downloader.cpp to std::string.
This has the side effect of fixing builds on Debian Trixie, which
currently fail with the (rather silly) error:
/build/subsurface-beta-202405060411/core/uemis-downloader.cpp: In function 'char* build_ans_path(const char*, int)':
/build/subsurface-beta-202405060411/core/uemis-downloader.cpp:290:32: error: '%s' directive output between 0 and 12 bytes may cause result to exceed 'INT_MAX' [-Werror=format-truncation=]
290 | snprintf(buf, len, "%s/%s", path, name);
| ^~
......
529 | ans_path = build_filename(intermediate, fl);
| ~~
cc1plus: some warnings being treated as errors
Signed-off-by: Richard Fuchs <dfx@dfx.at>
Fix a bug causing the 'Download from dive computer' dialogue to hang
when the user attempts to cancel the dialogue after successfully
downloading one or more dives.
Fixes#4176.
Signed-off-by: Michael Keller <github@ike.ch>
ae299d5e66 introduced a format-
string bug by splitting a format-string in two and splitting
the arguments at the wrong place.
The compiler doesn't warn in this case, because the format-
string is passed through translate(...).
This should have crashed, but for some reason didn't, at least
on Linux.
Fix the arguments.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Add logging of the libdivecomputer return code for errors. Also, switch
logging of errors in the background thread to callback based logging to
make it visible.
Signed-off-by: Michael Keller <github@ike.ch>
Fix the filters for planned (i.e. has at least one dive plan attached)
and logged (i.e. has at least one dive computer log attached) dives.
Also refactor the respective functions for improved readability.
Signed-off-by: Michael Keller <github@ike.ch>
Fix some findings in a Coverity scan in `core/planner.cpp` and
`core/profile.cpp`, that were reported as new after the changes
in #4126 (likely because of the rename from .c to .cpp).
Results: https://scan4.scan.coverity.com/#/project-view/60459/13160
Signed-off-by: Michael Keller <mikeller@042.ch>
Allows us to remove the strndup.h header. This code will be
even more simple, once core is fully converted away from C-strings.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The old code was leaking memory. Use std::unique_ptr<> for
ownership management.
This is still very primitive and divetags are kept during
application lifetime. There should probably be some form
of reference counting. And the taglist should not be global,
but attached to the divelog.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The only case left is in android.cpp, though that is only compiled
when compiling the full desktop app on Android. I.e. never. So
don't bother for now.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Let's use std::string in the core. Notably, I'd like to make
the numerous main() functions mostly independent of Qt. Some
things will have to remain, such as argument parsing, of course.
This changes the API: instead of returning an error code and
taking a pointer to the actual return-value, return an
std::optional<std::string>> that is set if the function succeeds.
Returning an empty string in the error case might be simpler,
but oh well...
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Use the C++-version of membuffer.
This fixes two memory leaks: report_info() on every(!) invocation
and report_error() before the error callback is set.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In C++ files, replace MIN and MAX by std::min and std::max,
respectively. There are still a few C files using these
macros. Convert them in due course.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Had to rewrite the thing, because gcc's warnings don't work
with templatized var-args. Since there is no string-format.cpp
and I didn't want to inline it, moved it to format.cpp.
String formatting is distributed around at least four
headers: membuffer.h, subsurface-string.h, format.h
and format-string.h. This really should be unified!
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Quite a bit of fallout in users of this structure.
Conveniently, since git-access.cpp is now C++ we can move
some helpers from the monstrous qthelper.cpp to git-access.cpp.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This may appear a bit ominous, as it doesn't generate a string,
but a vector of strings (one for each line). However, that is
in preparation for the QtQuickification of the profile, where
the text-items take such a list.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since this is the only caller, onvert the get_file_name() function
to return an std::string.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This used to have multiple values, but is currently only checked for
true/false. Reflect that in the type.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The deco timestep is a parameter to the plan() function. There
seems no need to define this as a global macro. Probably some
code reshuffeling artifact.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We had locale aware formatting functions that generated QStrings.
Create an alternative that creates std::string, since we want that
in the core.
This commit is unfortunate for two reasons:
- The function is called "casprintf()" for analogy with the QString
version. However, the non locale aware function is called
"format_string_std()" for analogy with "format_string()".
Ultimately these names should be unified. Probably, once there
are no membuffer users left.
- This does UTF-16->UTF-8->UTF-16 roundtrips. The core formatting
functions should render UTF-8 and only convert to UTF-16, in
the UI layer.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The combo-boxes (cylinder type, weightsystem, etc.) were controlled
by global models. Keeping these models up-to-date was very combersome
and buggy.
Create a new model everytime a combobox is opened. Ultimately it
might even be better to create a copy of the strings and switch
to simple QStringListModel. Set data in the core directly and
don't do this via the models.
The result is much simpler and easier to handle.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Remove the options to expand entities and so continue when encountering invalid /
malformed XML, as both of these can be exploited by supplying
maliciously crafted XML.
Signed-off-by: Michael Keller <mikeller@042.ch>
Q_FOREACH and foreach are anachronisms.
Range based for may cause a performance regression: it can
lead to a copy of shared containers (one reason why Qt's
COW containers are broken). However, as long as there is no
user noticeable delay, there is no point in analyzing each case.
And also no point in slapping an 'asConst' on every container
that is looped over.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To avoid memory management woes. These shouldn't be global
variables, but let's fix that later.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Downloder builds pull in show_computer_list() from
downloadfromdcthread.cpp, but it's declared as extern "C". With 76c2069f
having converted subsurfacestartup.c to .cpp, we can remove the extern
"C"
Signed-off-by: Richard Fuchs <dfx@dfx.at>
Add 'Country' to the fields that are indexed for fulltext search - this
seems to be a quite intuitive choice as 'Country' is also a field that
is available in the dive list view.
Fixes#4134.
Signed-off-by: Michael Keller <mikeller@042.ch>
Opportunistically fix some problems newly raised by a recent Coverity
scan.
Not touching any of the string memory allocation issues as this is being
handled by the move towards C++ strings.
Signed-off-by: Michael Keller <mikeller@042.ch>
printf() is a horrible interface as it does no type checking.
Let's at least use the compiler to check format strings and
arguments. This obviously doesn't work for translated strings
and using report_error on translated strings is dubious. But OK.
Had to convert a number of report_error() calls to supress
warnings.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
qthelper.h is an absolute monstrosity and it is unclear what
report_info and SSRF_INFO have to do with Qt.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This mimics the code added in commit cf990b0f39 ("preferences: choose language
code with one '-'") and adds some debugging for the mobile case - some people
are being presented with Subsurface-mobile in Korean for some reason.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When initializing a string with multiple characters, first
comes the length, then the size. Not the other way around.
Fixes#4127.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
On initialization, the old code searched for the first language
code containing a '-'. However, my Qt version gives de-Latn-DE
as the first entry. That messed up the preferences code: it
didn't recognize that entry. Thus, simply opening and closing
the preferences switched the language to Bulgarian.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There was a pattern of code like
match_action(line, state, dive_action, ARRAY_SIZE(dive_action));
The doubling of the array might cause copy & paste errors, where
only one array is replaced.
Therefore, determine the length of the array with (hopefully
easily understood) template tricksery.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When iterating over the converted strings of a line, the
first entry of the array would be popped off, leading to
a full copy of the remaining array.
Instead, use an index in the parser state.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The converted strings were stored in a membuffer and later
converted to std::strings. Generate an std::string directly
to avoid unnecessary copying.
Ultimately, when the core structures are converted to
std::string, there should be no copying of the string data
at all (unless formatting is applied or small string
optimization kicks in, of course).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Create a format_string_std function that works like format_string,
but does return a std::string instead of a strdup()ed C string.
Make it a global function to be used in other parts of the code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This avoid memory-management troubles. Had to convert a few
of the parsers (cochran, datatrak, liquivision) to C++.
Also had to convert libdivecomputer.c. This was less
painful than expected.
std::string is used because parts of the code assumes
that the data is null terminated after the last character
of the data. std::string does precisely that.
One disadvantage is that std::string clears its memory
when resizing / initializing. Thus we read the file onto
freshly cleared data, which some might thing is a
performance regression. Until someone shows me that this
matters, I don't care.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Return an std::string to avoid memory management headaches.
While doing that, convert time.c to C++ so that
format_datetime directly returns an std::string.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This was very annoying, because the old code was not const-clean
at all and trampled all over buffers. This makes the new code
pretty messy for now.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Make the memory management easier to follow. I feel that the old
code was leaking left and right, but not sure because it was so
intractable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Simplifies memory management. Think about unglobalizing this,
once everything is in C++ so that we can put an std::string
into struct divelog.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This includes using the C++ version of membuffer. There appears
to not have been a leak, because the buffer is freed in
flush_buffer(), but usage was somewhat inconsistent and hard to
follow.
Also, convert some string handling to std::string to avoid free()
madness.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
get_changes_made(), subsurface_user_agent() and normalize_cloud_name()
are only called from C++.
Avoids having to manually free the returned value and is therefore
more robust against leaks.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The code is now much easier to check for memory leaks,
since there are no explicit free()s. Yes, memory is not
released immediately, but that should be of no concern.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This changes default behavior when creating a sample struct
in C++ code: it is now initialized to default values. If this
ever turns out to be a performance problem, we can either add
additional constructors or use special functions that do
not initialize memory, such as make_unique_for_overwrite.
This removes non-standard (respectively >C++20) constructs,
namely designated initializers.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Avoid error-prone malloc/free pairs. This uses somewhat
obscure constructs to stay as close as possible to the
original C code. Notably, it uses mostly unique_ptr<T[]>
which doesn't store the length of the array, because the
length is supposed to be known.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Long term project: convert core to C++ so that we can
use higer-level constructs, notably std::vector<>.
This does not change any code - only fixes compile issues.
Mostly casting of (void *) to the proper type. Also designated
initialization of the sample struct had to be rearranged.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In the core, we usually want C strings, not QStrings. Therefore,
make translated C strings directly available from C++.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The function clear_*_table frees all elements of the table.
However, persumably as a performance feature, it kept the
memory of the table itselt (i.e. it only reset the number of
elements but kept the capacity).
That is fine if the table is reused later. However, this
function was also used when freeing the table and this
would leak the table memory.
This commit frees the table memory. An alternative would
be to have separate clear_*_table and free_*_table functions.
But let's wait with that until we port the table code to C++.
Then this will be "automatically" fixed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Firstly, why calculate something when the next statement is a return
anyway.
Secondly, the calculation subtracts two completely unrelated pointers.
This must be some code reshuffling artifact.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Add support for the new dive computer models that have been added in the
latest version of libdivecomputer.
Signed-off-by: Michael Keller <mikeller@042.ch>
Currently, the "hide event" status is lost when switching dives.
Save it in the event struct instead to make it persistent.
In the future we might save this information to the log file.
Then this should be integrated in the undo-system.
This commit also makes the "unhide events" menu entry more
fine grained: It now differentiates between individual
events and event types.
Note this adds an additional field to the event structure.
There is a "deleted" field that is used internally for
book-keeping, but probably should be removed. Not touching
this at the moment as long as this is C-only code. When/if
switching to C++ we can make the event linked list a table,
which will make this much simpler.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Currently the event type code uses libdivecomputer's flags
to differentiate between events. Make this explicit and extract
the event severity.
The reason is that later we want to be more explicit about showing/
hiding events and thereto we must format the name of events.
Moreover, this encapsulates the complexities of extracting
the severity in the event code (that used to be in the profile
code).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of passing name / flag pairs to event_type functions,
pass a pointer to the event. This hides implementation details.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This structure is used to hide events of a certain type.
The type was inferred from its name, but now includes flags.
So event_type is more appropriate.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Reinstate the hiding of events by event type across
all dives in the log. This was unintentionally removed in #3948.
Also change the event type to be specific to name and severity, and fix
bug causing 'Unhide all events' to not show when only individual events
were hidden.
This still leaves the inconsistency that hiding of similar events is
persisted across the switch between dives, but hiding of individual
events is lost when switching dives, which is mildly confusing.
Follow-up to #4092.
Signed-off-by: Michael Keller <github@ike.ch>
The planner uses a one-past-end pseudo cylinder for marking the
surface interval outside of water. This overflowed arrays in
setup_gas_sensor_pressure().
See #4086. Note: contains a second unrelated crash report.
As a band-aid allocate bigger arrays. But obviously, the proper
fix is to not generate invalid gas-change events.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Fix the configuration of the deco ceilings in the mobile version:
- make the settings work;
- remove reading of the dive computer ceiling from git;
- hide the gradient factor in the profile when the calculated ceiling is
not shown;
- when the calculated ceiling is disabled in the settings, disable
editing of the gradient factor.
Signed-off-by: Michael Keller <github@ike.ch>
If the XML document could not be parsed then `root_element` will come
out as NULL. Check this before trying to dereference it.
Signed-off-by: Richard Fuchs <dfx@dfx.at>
The Divesoft Liberty has four O2 sensors. So far, we had a hard coded
limit of three sensors and crashed with a failed assert when we
encoutered more than three. This allows for up to
MAX_O2_SENSORS which is currently 6. The voting logic is adapted
accordingly: We sort the values and we keep deleting the values that
differ more than 20% by value from the closest. This follows what
Shearwater implements on their computers.
In some of the import/export functions the value is still hard
coded to 6 thanks to explicit field names.
Signed-off-by: Robert C. Helling <helling@lmu.de>
fp_get_data() returns a copy of a string that must be freed.
Fix this in save-git.c. The analogous function in save-xml.c
has already been fixed. However, change the code to be more
idiomatic: since we own the pointer, make it "char *" instead
of "const char *". Then we don't have to cast on free().
Ultimately, we really should change string manipulation code
to C++.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Mostly irrelevant std::move() stuff of copy-on-write Qt objects,
a few real bugs, a timestamp_t downconversion and some codingsyle
adaptation.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
If prefs.show_icd is false, this function does nothing, but
the output parameter is checked by the calling function
DiveEventItem::setupToolTipString().
Let's reset the strucvture to 0.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When adjusting picture times, the offset in seconds is stored in a
32-bit int. Make it a 64-bit int. Sounds crazy, because why would
you want to move the pictures by more than 70 years?
Well, suppose it is the year 2039, for some strange reason your
camera was set to unix epoch and you want to adjust the pictures
to current time.
Ok - that's a far-fetched scenario. The real reason is that this
hopefully silences a Coverity warning and avoids integer casting.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Unfortunately Coverity doesn't understand that most Qt data
structures are copy-on-write. It's a mis-feature of Qt, but
it is the way it is. Thus, passing by value is not an issue.
Out of ca. 25 warnings only two were legit. Let's silence
the others by either std::move()ing or passing by reference,
as would be idiomatic C++, which Qt is not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There are two enums related to the type of dive.
There is the global
enum divemode_t {OC, CCR, PSCR, FREEDIVE, NUM_DIVEMODE,
UNDEF_COMP_TYPE};
and the anonymous
enum {AIR, NITROX, TRIMIX, FREEDIVING} dive_type;
in struct plot_info.
In profile.c FREEDIVE (of divemode_t) is assigned to dive_type.
This only works because by chance(?) FREEDIVE and FREEDIVING are
the fourth element of each enum.
Fix this. C truly is a bad language when it comes to types
(very weak) and namespaces (non existing).
Contains whitespace fix.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This hasn't been used on the backend in a long time (and appears to get
stripped out on several platforms). No point in keeping it around.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While the update to the copyright year really isn't required, it just looks
better.
By using the canonical instead of the git version in user visible strings we
are creating more consistency in how we refer to the version.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
- for now all versions start with v6.0
- CICD builds use the monolithic build number as patch level, e.g. v6.0.12345
- local builds use the following algorithm
- find the newest commit with a CICD build number that is included in the
working tree
- count the number of commits in the working tree since that commit
- if there are no commits since the last CICD build, the local build version
will be v6.0.12345-local
- if there are N commits since the last CICD build, it will be
v6.0.12345-N-local
- test builds in the CICD that don't create artifacts simply use a dummy release
in order to not incorrectly increment the build number and also not to waste
time and resources by manually checking out the nightly-build repo for each of
these builds.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Increase the precision of the setpoint that can be specified per planned
leg of the dive to 0.01 mbar.
Some rebreather models (APD Inspiration) support this precision for
setpoint setting.
Motivated-by: https://groups.google.com/g/subsurface-divelog/c/pD5gYlG5szI/m/G8_as4TyBwAJ
Signed-off-by: Michael Keller <github@ike.ch>
I ran into this a couple of times where the debug output didn't seem to
make any sense until I understood that libgit simply didn't give me
detailed error info.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is not a great way to load-balance, but it works and doesn't require
high end hardware on the backend.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If there are no gas mixes returned by libdivecomputer, we need to default to air. The previous commit would have defaulted to pure oxygen.
Signed-off-by: Micha WERLE <micha@michaelwerle.com>
During code review, an argument was made to use the bottom gas mix as
the mix to fill additional tanks with instead of the last mix reported
by the dive computer.
This change implements `get_deeper_gasmix` which compares two gas mixes
and returns the one with the lower MOD. This comparison does not perform
actual MOD calculations but only performs a relative oxygen and helium
content comparison.
Instead of saving the last gas mix and assigning it to additional tanks,
a `bottom_gas` mix is saved and assigned instead.
Signed-off-by: Micha WERLE <micha@michaelwerle.com>
Reverted "optimisation" based on code feedback.
Firstly, it's implementation-defined whether or not a stack frame is created for sub-scopes, secondly any optimisation is questionable regardless, and thirdly it was felt that it makes the code harder to understand.
Signed-off-by: Micha WERLE <micha@michaelwerle.com>
Instead of defaulting to air when we run out of gas mixes to assign to
cylinders, use the last gas mix provided by the dive computer.
If no gas mixes are provided at all, then default to air.
This prevents Subsurface from "inventing" gas mixes which are not
reported by the dive computer. It also works very nicely with a sidemount
configuration where the dive computer typically reports two cylinders but
only a single gas mix.
Signed-off-by: Micha WERLE <micha@michaelwerle.com>
The divecomputer_device_open() function tries all supported transports
one by one, and exits as soon as one is opened successfully. When the
end of the function is reached, the DC_STATUS_UNSUPPORTED error code is
returned.
The annoying side effect is that the actual error code returned by the
transport is ignored and changed into DC_STATUS_UNSUPPORTED. This is
very confusing while troubleshooting download problems.
Fixed by initializing the error code to DC_STATUS_UNSUPPORTED, in case
no transport is available for trying, and returning the last reported
error to caller.
Signed-off-by: Jef Driesen <jef@libdivecomputer.org>
Add the Aqualung i330R and Apeks DSX model numbers to the Pelagic
pattern table. These two models also use a new BLE service UUID.
Signed-off-by: Jef Driesen <jef@libdivecomputer.org>
The UUID of the Divesoft BLE service needs to be added to the list of
known services. It's a 16-bit UUID that gets detected as a standard
service and is ignored otherwise.
Signed-off-by: Jef Driesen <jef@libdivecomputer.org>
When we've already seen a trimix gas, of we after that see a nitrox gas
with less o2, it shouldn't update the mino2 state.
Signed-off-by: Anton Lundin <glance@ac2.se>
When the import from a dive computer gives you 100% as the first gas,
the get_dive_gas never finds which gas had the lowest o2 percent.
This fixes the logic to find the lowest o2 percent in any dive cylinder
list.
Signed-off-by: Anton Lundin <glance@ac2.se>
It looks kinda strange that all CCR dives have a dive gas ..100%, so
rather than showing it as the dive gas used, just ignore cylinders
with usage flagged as oxygen.
Signed-off-by: Anton Lundin <glance@ac2.se>
If enabling the notification fails, receiving data packets is not
possible. Instead of silently ignoring this fatal problem and trying to
continue, report the error back to the caller.
Signed-off-by: Jef Driesen <jef@libdivecomputer.org>
The existing logic correctly calculates the minimum (ie, ending) pressure, but not the maximum
(ie starting) pressure.
For example, 2 tanks A and B with manual pressures (same tank on subsequent dives, which were
then merged):
A: 205 - 84
B: 83 - 55
When merging the starting pressures, the call is : merge_pressure(205, 0, 83, 0, false)
The final comparison is:
if(false && 205 < 83) return 205;
else return 83;
-> So 83 is returned even though 205 should have been.
Signed-off-by: Michael Werle <micha@michaelwerle.com>
When events are hidden in the profile, only hide events with the same
name and the same severity (flags).
From discussion in https://github.com/subsurface/libdc/pull/54.
Signed-off-by: Michael Keller <github@ike.ch>
Fix how gases are marked as 'used' and kept from being deleted in the
equipment tab for CCR dives.
It does not make sense to treat the (arbitrary) first gas in the list
with a usage type of 'diluent' or 'oxygen' as 'used' and prevent the
user from deleting it. Dive computers report the initial diluent and
any other diluents used through a 'gaschange' event, so the actually
used diluents are already picked up as part of gaschange event based
logic.
Also clarify the selection of the first diluent used as a default if no
gaschange events exist.
Also fixed the test data - gases that have a pressure change should be
included in the profile if they do not have a gas change recorded
against them by other dive computers, even if they are oxygen.
A secondary problem shown by this is that the pressure change is not
applied to the profile - the pressure is currently shown as constant on
the start pressure. But this is for another pull request.
Signed-off-by: Michael Keller <github@ike.ch>
Include unused tanks in merges of multiple logs into a single dive if
the 'Show unused cylinders' preference is enabled.
Also rename the preference (in code) to `include_unused_tanks` to
reflect the fact that it is already used in more places than just the
display (exporting, cloning dives).
Simplified the cylinder model to make forced inclusion of unused tanks
dependent on use of the model in planner.
Leaving the persisted name of the preference as `display_unused_tanks`
to avoid resetting this for all users - is there a good way to migrate
preference names?
Signed-off-by: Michael Keller <github@ike.ch>
Mark gases that are reported as 'inactive' by the dive computer as 'not
used' in the Equipment tab.
Requires https://github.com/subsurface/libdc/pull/52.
Signed-off-by: Michael Keller <github@ike.ch>
The conversion between mbar and depth sometimes uses DC's salinity, sometimes user's salinity. By other hand, it uses surface pressure given by user in calculation.
This fix try to standartize this values, using them from same source.
Signed-off-by: Rafael M. Salvioni <rafael.salvioni@gmail.com>
Add a button that allows the user to hide the infobox with statistics
about the point in the dive under the mouse cursor in order to be able
to see the full dive profile unobstructed.
Signed-off-by: Michael Keller <github@ike.ch>
Add meaningful error messages when creating a libdivecomputer dump. In
particular show if creating a dump is not supported on the dive computer
that is used.
Signed-off-by: Michael Keller <github@ike.ch>
The memory management and string concatenation was hard to follow.
Since the mobile files ios.cpp and android.cpp were already
converted to C++, let's do the same for Unix, Windows and MacOS.
Simply store the default directory and filename in a function-level
static string. Thus, it will be initialized on first call and
freed on application exit. Since the std::string data is
guaranteed to be contiguous and zero-terminated, it can be used
from C code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Add support for tracking the gas usage across multiple tanks to the 'bar
used' and SAC values shown for the profile ruler.
The following rules are implemented:
- a tank is considered 'used' if at least one bar has been consumed;
- only used tanks are taken into account for calculations;
- 'bar used' is only shown if all tanks used have the same (or unknown)
volume;
- SAC is only shown if all tanks used have a known volume.
Fixes#3902.
Reported-by: @pabdakine
Signed-off-by: Michael Keller <github@ike.ch>
Remove `renderSVGIcon()` and `renderSVGIconWidth()`, as QPixmaps can be
loaded directly from SVG, and support scaling.
Signed-off-by: Michael Keller <github@ike.ch>
It's possible for the first sensor to start with a pressure
significantly lower than other sensors.
Signed-off-by: Michael Andreen <michael@andreen.dev>
This has to be applied to the object, not the pointer to the object.
Fixes a double-free crash introduced in 8cd451f.
Alternatively, we could use std::swap() for C++98 charm and perhaps
better readability for people unfamiliar with C++11. Nowadays,
std::move() is more idiomatic though. Shrug.
Reported-by: Michael Keller <github@ike.ch>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Add an option for users to sync the dive computer time with the PC time
every time dives are downloaded.
Obviously this will only work on dive computers that have time
synchronisation support in libdivecomputer, for other computers a notice
is logged.
The selection for this option is persisted as a preference.
Signed-off-by: Michael Keller <github@ike.ch>
The undo-code uses owning pointers based on std::unique_ptr to
manage lifetime of C-objects. Since these are generally useful,
move them from the undo-code to the core-code. In fact, this
eliminates one instance of code duplication.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
displayed_dive used to contain the currently displayed (as in
shown on the profile) dive. However, now it is only a "scratch"
dive used by the planner and initialized every time the planner
is started. There is no point in clearing this dive when clearing
the dive data. In fact, the dive should probably be cleared when
the planner finishes.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The current dc global makes no sense on mobile. Therefore,
move the logic of the currently displayed dive computer
to the profile widget and remove the dc_number global
variable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This was very weird: a setSelection() call was always followed
by a selectionChanged() call, though sometimes in convoluted
ways. Notably, the formed was called by the DiveListView, the
lattern then by the MainWindow.
Let's just merge these two functions.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The trip selection code was an awkward layering violation.
Whereas dive selections due to dive undo-commands trickled
down via DiveTripModel-->MultiFilterSortModel-->DiveListView,
for trip editing, the DiveListView directly intercepted the
TripEdited signal.
Instead, mimic the dive-selection code. This is a bit longer
but more consistent and logical. The undo/redo of trip changes
is now also a "programmatical" change of the selection.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
After sending a selection-change signal, there follows a current
dive changed signal. Combine these two into a single signal, since
usually the current dive is changed when the selection is changed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
These were not optimal, because they would recalculate the current
dive and divecomputers for every invocation.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
delete_single_dive() is one of those remnants from before the
undo-code. Now it is only called in two contexts:
1) When clearing the whole dive log.
2) When importing dives from the cloud on mobile.
In the first case, the selection is cleared before deleting
the dives.
In the second case, let's just do the same.
Thus, we can remove the last call to the deselect_dive()
function that does some complex calculations concerning
the current dive and divecomputer.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Each of these calls recalculates the current dive and divecomputer.
Instead, collect the dives to be selected/deselected and (de)select
them at once.
This needs some code refactoring in the core, because we need a
function that
1) doesn't send a signal by itself.
2) doesn't clear the trip-selection.
This contains some reorganization of the selection functions
signatures: The filter code is the only caller that keeps the
selected dive and the only caller that cares about whether the
current dive changed. So let only the function that keeps the
selected dive return whether the current dive changed.
It's all very fragile.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
For each selected dive that is hidden by the filter,
unselect_dive() was called, which led to a recalculation
of the current dive and divecomputer.
Instead, collect all deselected dives and deselect them
at the end. Thus, these calculations are performed
only once.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This tries to encapsulate the management of the current dive and
divecomputer in the selection code. The current dive is alreay
set by setSelection(). Add a new parameter to also set the
current divecomputer. If -1 is passed, then the current
computer number is remained. This will allow us to audit the code.
Because for now, the whole "current dive computer" thing seems
to be ill-defined.
This fixes a bug: the dive-computer number wasn't validated
when making a new dive the current dive. The new code has some
drawbacks though: when selecting a whole trip, the validation
will be called for all dives in the trip and thus the dive computer
number will depend on the dive with the lowest amount of dive
computers in the trip. This will need to be fixed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This removes a constant describing the length of the array.
The enumerated_range code had to be adapted, because the
interaction of C-type arrays with the C++ typesystem is mad.
With C-type arrays, one has to pass a reference to std::declval.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The parser API was very annoying, as a number of tables
to-be-filled were passed in as pointers. The goal of this
commit is to collect all these tables in a single struct.
This should make it (more or less) clear what is actually
written into the divelog files.
Moreover, it should now be rather easy to search for
instances, where the global logfile is accessed (and it
turns out that there are many!).
The divelog struct does not contain the tables as substructs,
but only collects pointers. The idea is that the "divelog.h"
file can be included without all the other files describing
the numerous tables.
To make it easier to use from C++ parts of the code, the
struct implements a constructor and a destructor. Sadly,
we can't use smart pointers, since the pointers are accessed
from C code. Therfore the constructor and destructor are
quite complex.
The whole commit is large, but was mostly an automatic
conversion.
One oddity of note: the divelog structure also contains
the "autogroup" flag, since that is saved in the divelog.
This actually fixes a bug: Before, when importing dives
from a different log, the autogroup flag was overwritten.
This was probably not intended and does not happen anymore.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Some DCs only report water type, without salinity level. Subsurface
fixes most of these cases using default levels, but when the type of water
is Sea/Salt, this fix was not saved.
This causes a bit confusion, mainly if the user defines own salinity level.
Signed-off-by: Rafael M. Salvioni <rafael.salvioni@gmail.com>
Since the only caller was C++ code, this can be done in
C++ code, which removes memory-management headaches.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In order to support development of the open source firmware of the
OSTC4.
Requires changes in libdivecomputer.
Signed-off-by: Michael Keller <github@ike.ch>
Fixes a bug reported in
https://groups.google.com/g/subsurface-divelog/c/8N3cTz2Zv5E:
When planning a CCR dive with multiple segments, the textual dive plan
was showing a non-existent gas change with bogus data. The first part
of the fix is uncluttering of the message printed: Since this change is
_after_ the current diveplanpoint the data needs to come from `nextdp`
and not `dp`. The second part is that the message is not printed any
more if the current and the following segments have been manually added:
According to comments in the code the change should only be printed on
the segment _before_ the change if this segment is an ascent segment
that is followed by a manually entered segment.
Signed-off-by: Michael Keller <github@ike.ch>
The event names were registered in add_event(). However,
the undo system did not use that function, but add_event_to_dc(),
which takes an already allocated event.
That gave the following unfortunate situation:
Load a log without setpoint changes.
Add a setpoint change.
The setpoint change event type now was not registered and
therefore couldn't be hidden.
Admittedly, a subtle bug, but still a bug. Fix by registering
event names on event creation.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The eventname handling code was splattered all over the place.
Collect it in a single source file and use C++ idioms to avoid
nasty memory management. Provide a C-only interface, however.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Changed the way dive data points for OC cylinders to be added to the
dive plan are created in `createTemporaryPlan()` in
`diveplannermodel.cpp`. This now uses `plan_add_segment()` like all
other places where dive data points are added, in particular the planner
tests.
This also allowed for `create_dp()` to be made static.
Signed-off-by: Michael Keller <github@ike.ch>
Fixes a bug reported in
https://groups.google.com/g/subsurface-divelog/c/8N3cTz2Zv5E:
When planning a CCR dive with OC bailout, the diluent gas may be chosen
as the first OC bailout gas, despite being set up with a use type of
'diluent', and likely not being available for open circuit breathing.
`best_first_ascend_cylinder` is now initialised to an invalid value
(instead of the first cylinder, which may or may not be a diluent
cylinder), and its subsequent use is guarded by a validity check.
Signed-off-by: Michael Keller <github@ike.ch>
Change the values supplied in the warning to be fractions. This is what
is actually reported by libdivecomputer. The currently used thousandths
are hard to interpret for users, as they are only used internally in
Subsurface.
Signed-off-by: Michael Keller <github@ike.ch>
Fix bug introduced in #3576: On CCR dives cylinders listed as open
circuit bailout by the dive computer need to be set to `OC_GAS`.
Signed-off-by: Michael Keller <github@ike.ch>
These were two weird and clearly wrong constructs of the
type "if (iter && iter + 1)", where iter is a pointer. This
is always true at best and undefined at worst. Another
instance was removed in 096de0efd0.
The original code probably wanted to check whether the
found character was the last character in the string.
But that likewise seems to make no particular sense in
this context. Therefore, just remove the second part of
the boolean expression.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of adding all gases read from a dive computer as part of a dive
log as 'OC-gas', add gases as 'diluent' if the dive has a dive mode of
'CCR'. This creates consistency with the ppO2 for CCR dives being
tracked as sensor readings or a fixed setpoint, and not as the ppO2 of
the current gas ad depth.
A follow up question from this is whether gas use in the cylinders list
on the Equipment tab should be user editable. This seems to be
inconsistent at the moment, with gas constituent percentages downloaded
from the dive computer being editable, but gas use not.
Signed-off-by: Michael Keller <github@ike.ch>
`device_data_t data` in DeviceDetails has never been populated since it was first
added, and consequently is not used. This is confusing, especially as certain
fields inside `device_data_t` have been added directly to `DeviceDetails` in the meantime (e.g. `firmwareVersion`).
Separated from #3568 as per
https://github.com/subsurface/subsurface/pull/3568#pullrequestreview-1274995287.
Signed-off-by: Michael Keller <github@ike.ch>
When exiting the loop, stopidx is 0, which means that if there
are no stoplevels, stoplevels[stopidx + 1] generates an
out-of-bounds access. Instead, suppose a stop at 3m or 10ft.
Suggested-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When loading a git repository, dive sites where loaded into the
global dive site table, not the local table. Apparently, nobody
ever tried to import a git repository into an existing divelog
(as opposed to opening it in the application). Because that would
have probably given funky results.
Remove this access of a global variable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When collecting the data for the infobox, we have
already computed the current partial pressures of the
breathing gas taking into accoutn the divemode. Use
those rather than fractions (which for CCR mode are
those of diluent) to compute the gas density.
Reported-by: Pietro Tranquillini <p.tranquillini@gmail.com>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Most of these declared non existing functions or pointers.
One [get_gas_idx()] was only used in one source file and
doesn't have to be globally accessible
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Search the index of an item in a container. Compare by
equality or a lambda. The lack of these have annoyed me for a
long time. Return the index of the first found element or
-1 if no element found.
Currently, only supports random-access operators. Might be
trivially changed for forward iterators.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The chances that their are still users of the old thumbnail
format (i.e. all thumbnails saved in the hash file) are basically
0. If there are they will just get their thumbnails rebuilt
when opening the individual dives.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>