This implicitly accessed the global divelog. Most of the users were
in the test/ folder anyway. Replace by explicit accesses to the
global divelog.dives.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
These functions accessed the global divelog make this explicit.
I'm still not happy about the situation, because these functions
access global state, such as the selection. I think these
should be moved up the call-chain.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This function implicitely accessed the global divelog. To make
that explicit make it a member of dive_table, such that the
caller must access it via the global variable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This one is for symmetry with unregister_dive(). However, it
makes me unhappy, because it modifies global state, namely the
selection machinery and the fulltext. I think these should be
moved up in the call chain.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This function implicitely accessed the global divelog. To make
that explicit make it a member of dive_table, such that the
caller must access it via the global variable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This function implicitely accessed the global divelog. To make
that explicit make it a member of dive_table, such that the
caller must access it via the global variable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This function implicitely accessed the global divelog. To make
that explicit make it a member of dive_table, such that the
caller must access it via the global variable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The parser used to append each parsed dive at the end of the log.
At the end the list was sorted. However, the divelist code depends
on the list being sorted. To avoid inconsistent states, add the
dives at the proper position.
Note that the reference data of TestDiveSeabearNewFormat had to
be adapted, because the CNS calculation now gives a different
value. This shouls be investigated.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
That was the only user of this helper function, so move it there.
Moreover, impelement it with the standard function std::from_chars
instead of copying the string.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is a messy commit, because the "qPref" system relies
heavily on QString, which means lots of conversions between
the two worlds. Ultimately, I plan to base the preferences
system on std::string and only convert to QString when
pushing through Qt's property system or when writing into
Qt's settings.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since all code can now directly access C++ structures these
accessor functions were not necessary.
Split out the table from the filterconstraint source file
and include it directly into the divelog.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Having this as a pointer is an artifact from the C/C++ split.
The triptable header is small enough so that we can
include it directly
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Having this as a pointer is an artifact from the C/C++ split.
The divesitetable header is small enough so that we can
include it directly.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Not strictly necessary, but a "natural" thing to do in a classical
C++ code base.
Move the tiny trip-table into its own source file, since it also
has its own header.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is a humongous commit, because it touches all parts of the
code. It removes the last user of our horrible TABLE macros, which
simulate std::vector<> in a very clumsy way.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Nothing against free-standing functions, but in the case
of dc_watertemp(), dc_airtemp(), endtime() and totaltime(),
it seems natural to move this into the dive class and avoid
polution of the global name space.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There was a weird asymmetry, where the undo-commands would
register the fulltext index of the dive, but the core would
unregister the fulltext index in the "unregister_dive()"
function.
To make this more logical, create a "register_dive()" function
in core that does registers the fulltext index.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This was a plain pointer owing to C compatibility.
Replacing it by a unique_ptr<> allows us to make it
'self-desctruct' in the constructor. However, we do this
with a special twist: the data is _not_ copied when copying
the dive, since the copied dive is not registered in the fulltext
system. Hackish, but it should(!) work.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The dive_table will be converted into a table of owning pointers.
Since the trip has only non-owning pointers to dives, turn
its dive_table into an std::vector<dive *>.
Add a helper functions to add/remove items in a sorted list.
These could be used elsewhere.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Don't access the global trip_table in an attempt to cut down
on implicit accesses of global variables.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since the sorted_owning_table depends on the fact that
different elements never compare as equal, make the
comparison function safer in that respect. If all failes,
compare the pointers.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
That was used to parse C-style strings. It was fully replaced
the the std::string version utf8_string_std().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This had to be done simultaneously, because the table macros
do not work properly with C++ objects.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since struct divecomputer is now fully C++ (i.e. cleans up
after itself), we can simply turn the list of divecomputers
into an std::vector<>. This makes the code quite a bit simpler,
because the first divecomputer was actually a subobject.
Yes, this makes the common case of a single divecomputer a
little bit less efficient, but it really shouldn't matter.
If it does, we can still write a special std::vector<>-
like container that keeps the first element inline.
This change makes pointers-to-divecomputers not stable.
So always access the divecomputer via its index. As
far as I can tell, most of the code already does this.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Not strictly necessary, but more idiomatic C++ and less
polution of the global namespace. This one is so trivial
that there seems to be no reason not to do it.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
add_sample() was used in only one place, and the return value was
always ignored. It took a time parameter, suggesting that a sample
could be added anywhere, but in reality the sample was added at
the end of the list. It used prepare_sample() that copies data
from the previous sample, just to overwrite it with the newly
added sample.
All in all very weird. Simplify the function: just append the
passed in sample and name it accordingly.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is a rather long commit, because it refactors lots of the event
code from pointer to value semantics: pointers to entries in an
std::vector<> are not stable, so better use indexes.
To step through the event-list at diven time stamps, add *_loop classes,
which encapsulate state that had to be manually handled before by
the caller. I'm not happy about the interface, but it tries to
mirror the one we had before.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since the name of an event is not incorporated into the even
structure anymore, we don't need these shenanigans. Just assign
the event name.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is a hairy one, because the sample code is rather tricky.
There was a pattern of looping through pairs of adjacent samples,
for interpolation purposes. Add an range adapter to generalize
such loops.
Removes the finish_sample() function: The code would call
prepare_sample() to start parsing of samples and then
finish_sample() to actuall add it. I.e. a kind of commit().
Since, with one exception, all users of prepare_sample()
called finish_sample() in all code paths, we might just add
the sample in the first place. The exception was sample_end()
in parse.cpp. This brings a small change: samples are now
added, even if they could only be parsed partially. I doubt
that this makes any difference, since it will only happen
for broken divelogs anyway.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This allows us to use non-C member variables. Convert a number
of pointers to unique_ptr<>s.
Code in uemis-downloader.cpp had to be refactored, because
it mixed owning and non-owning pointers. Mad.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Some compilers whine when using typedefs with non-C structs with
default initializers. Not yet the case here, but in the future
probably will. So remove them now. No point in C++ anyway.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
They make no sense under C++ and seem to produce tons of warnings
on some compilers (Apple).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Wuth C++ the distinction between "typedef" and regular "struct"
makes no sense anymore. Remove the typedefs, it's just confusing.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since everything is C++ now, we can use unique_ptr<>s. This makes
the code significantly shorter, because we can now use the default
move constructor and assignment operators.
This has a semantic change when std::move()-ing the divelog:
now not the contents of the tables are moved, but the pointers.
That is, the moved-from object now has no more tables and
must not be used anymore. This made it necessary to replace
std::move()s by std::swap()s. In that regard, the old code was
in principle broken: it used moved-from objects, which may work
but usually doesn't.
This commit adds a myriad of .get() function calls where the code
expects a C-style pointer. The plan is to remove virtually all of
them, when we move free-standing functions into the class it acts
on. Or, replace C-style pointers by references where we don't support
NULL.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There were only two of them, from the time C-code had to access
the divelog: clear_divelog() and delete_single_dive().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This was the only dive_site_table function that accessed
to global divelog, which is odd. Make it consistent with
the others.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
After all it doesn't access any dive_site structure.
Moreover, rename it, since we use mostly snake_case in core.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This gives the distance between to location_t objects. It is
unclear why this was in divesite.cpp.
Moreover pass by value, not raw pointer.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There were a number of free standing functions acting on a
dive-site-table. Make them member functions. This allows
for shorter names. Use the get_idx() function of the base
class, which returns a size_t instead of an int (since that
is what the standard, somewhat unfortunately, uses).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This makes memory management more simple, as not explicit deletion
is necessary.
A rather large commit, because changing QVector<> to std::vector<>
is propagated up the call chain.
Adds a new range_contains() helper function for collection
types such as std::vector<>. I didn't want to call it
contains(), since we already have a contains function
for strings and let's keep argument overloading simple.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is a long commit, because it introduces a new abstraction:
a general std::vector<> of std::unique_ptrs<>.
Moreover, it replaces a number of pointers by C++ references,
when the callee does not suppoert null objects.
This simplifies memory management and makes ownership more
explicit. It is a proof-of-concept and a test-bed for
the other core data structrures.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This the C++ version of membuffer. Since everything is C++, it can
just be made the default.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Also remove the UNUSED() macro, as there were no users left.
The macro was silly anyway - there were many falso positives.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We can now return mutable/imutable depending on const-ness of
the parameter, owing to parameter overloading.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Makes the code much nicer to read.
Default initialize cylinder_t to the empty cylinder.
This produces lots of warnings, because most structure are now
not PODs anymore and shouldn't be erased using memset().
These memset()s will be removed one-by-one and replaced by
proper constructors.
The whole ordeal made it necessary to add a constructor to
struct event. To simplify things the whole optimization of
the variable-size event names was removed. In upcoming commits
this will be replaced by std::string anyway.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To my understanding, declaring empty parameter lists using "(void)"
is an artifact from the bad old K&R times, when functions were
declared without(!) parameters. Which in hindsight was an absolute
recipe for disaster. So for backwards compatibility, functions
without parameters had to be declared using "(void)" as "()"
could also mean "any function".
That was 40 years ago. Meanwhile, C++ introduced references,
which made it a necessity to declare the function parameters.
So "(void)" is redundant and inconsistent in C++ code and
just makes no sense.
Remove it.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The divesite-helper.cpp only existed because C-string manipulation
was too tedious. Now that divesite.cpp is C++ anyway, the split
is not necessary anymore.
Moreover, return an std::string, since this is a core-function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since this is now in C++, we don't have to use our crazy
TABLE_* macros.
This contains a logic change: the dives associated to a
dive site are now unsorted.
The old code was subtly buggy: dives were added in a sorted
manner, but when the dive was edited the list was not
resorted. Very unlikely that this leads to a serious
problem, still not good.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since the taxonomy is now a real C++ struct with constructor
and destructor, dive_site has to be converted to C++ as well.
A bit hairy for now, but will ultimately be distinctly simpler.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Use std::vector<> instead of fixed size array.
Doesn't do any logic change, even though the back-translation
logic is ominous.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Use more C++ style memory management for plot_info: Use std::vector
for array data. Return the plot_info instead of filling an output
parameter. Add a constructor/destructor pair so that the caller
isn't bothered with memory management.
The bulk of the commit is replacement of pointers with references,
which is kind of gratuitous. But I started and then went on...
Default initializiation of gas_pressures made it necessary to convert
gas.c to c++, though with minimal changes to the code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Replace malloc/free of one structure by C++ idioms and add a
destructor to the struct. Otherwise, don't touch the code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
It seems that smartrak was the only part of the code that cared
about freeing the dc_descriptor. Make that a general feature
of the new device_data_t destructor, which we could implement
now that things are in C++.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
It was never clear what was a pointer to a static string from
libdivecomputer and what was allocated.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
These can all just be local objects.
Also, don't overwrite them with 0. We later want to convert the
string to std::string, where this would be very sketchy.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Convert both files simultanously, because the SI_UNITS define works
either under C or under C++.
This was painful, because initialization of struct-members has to
be done in order of definition in C++. And it was completely out
of order. However, as long as not all is C++, we can't use
default initialization directly in the struct definition. :(
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The old code was wild: For the yearly statistics it would allocate
one entry per dive in the log. Of course, it would also leak
C-style strings.
Convert the whole thing to somewhat idiomatic C++.
Somewhat wasted work, because I'd like to convert the whole thing
to the new statistics code. But let's finish the conversion to C++
first.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
All have been converted to std::min() and std::max().
Moreover, this was Windows only and since we cross-compile, it
is not even clear if this is needed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>