Commit graph

20004 commits

Author SHA1 Message Date
Berthold Stoeger
2f4dbf1848 core: make get_sha() return std::string
This was crazy: it returned a local static buffer, i.e. was
inherently non-reentrant.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
2f3d8d83f5 core: port printGPSCoordsC to return std::string
Less memory management hassle.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
119fe908c7 core: port filterpreset.cpp to std::string
Less memory management hassle.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
2e1d852e36 core: convert filter_constraint_data_to_string to C++
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>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
898ecd2df5 core: make fp_get_data return an std::string
No need for manual memory management.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
8d96b7557d core: convert parser_state to C++
Add constructor, destructor and use std::string for memory
management of text data.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
5e466d91f0 core: convert core/import-*.c to C++
import-csv.c was crazy with implicit (const char *) to (char *)
conversions!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
83b0c1da40 core: convert parse-xml.c and parse.c to C++
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>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
a133c6c4db mobile: turn testqml into a std::string
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
9509eb6876 divetripmodel: explicitly convert char * to QString
The automatic conversion from char * to QVariant failed to
compile for me. Let's hint that this should be interpreted
as a string. No idea, why this happens for me, but apparently
not on CI.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
43ec3fc1d9 core: use std::string in load-git.cpp
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>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
114513493b core: use std::string in parser state of git loader
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
a1826f77da core: turn saved_git_id into a std::string
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>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
c05be40bfd core: convert load-git.c to C++
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
d803e42314 core: convert file.c to C++
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
a032d9c979 core: convert save-xml.c to C++
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>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
76c2069fa8 core: port subsurface-startup.c to C++
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
f1012283a0 core: turn a few string helpers into C++
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>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
924b23ed56 core: convert git-access.c to C++
Had to make sha.h compatible with C++.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
b0438ad1dd core: use C++-style memory management for struct dir
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>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
371b155922 core: convert core/save-git.c to C++
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
148775f418 core: convert sample.c to C++ and add default constructor
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>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
c27e093ebd core: replace dynamic arrays in dive.cpp by C++ constructs
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>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
52e6a098aa core: convert dive.c to C++
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>
2024-03-10 11:01:42 +13:00
Berthold Stoeger
096e49e15b core: make translate() accessible from C++
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>
2024-03-10 11:01:42 +13:00
Dirk Hohndel
649ed8a9ae Merge remote-tracking branch 'origin/translations_translations-subsurface-source-ts--master_ca' 2024-03-08 15:16:23 -08:00
Dirk Hohndel
569c5520af Merge remote-tracking branch 'origin/translations_translations-subsurface-source-ts--master_nl_NL' 2024-03-08 15:15:53 -08:00
Dirk Hohndel
5dc4c5855b Merge remote-tracking branch 'origin/translations_translations-subsurface-source-ts--master_en_GB' 2024-03-08 15:15:18 -08:00
Dirk Hohndel
af8f67ed5f Merge remote-tracking branch 'origin/translations_translations-subsurface-source-ts--master_de_DE' 2024-03-08 15:14:38 -08:00
Berthold Stoeger
9d2bd425e1 core: fix memory leak in tables code
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>
2024-03-07 07:55:23 -05:00
transifex-integration[bot]
4b1a6f8824
Translate translations/subsurface_source.ts in ca
100% translated source file: 'translations/subsurface_source.ts'
on 'ca'.
2024-03-04 01:40:49 +00:00
transifex-integration[bot]
6c2b126c8e
Translate translations/subsurface_source.ts in ca
100% translated source file: 'translations/subsurface_source.ts'
on 'ca'.
2024-03-04 01:40:34 +00:00
Berthold Stoeger
805cd550f2 cleanup: fix memory leak
get_local_dir() returns the copy of a c-string. It therefore
has to be free()d.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-03 14:59:31 -08:00
Berthold Stoeger
a4091189b0 cleanup: use proper size when allocating string
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 19:21:59 +01:00
Berthold Stoeger
ef5859437a cleanup: remove ominous pointer calculation
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>
2024-03-01 12:28:52 -08:00
Michał Sawicz
96470227d5 snap: fix grade determination
Determine grade based on whether we actually managed to check out the
buildnumber.

This assumes that the tree is clean for building a stable snap (one that
can be published to candidate and stable channels).

Signed-off-by: Michał Sawicz <michal@sawicz.net>
2024-03-01 09:03:28 -08:00
Berthold Stoeger
cb3e21c443 cleanup: remove unused data and bogus UNUSED in libdivecomputer.c
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-01 07:57:34 -08:00
transifex-integration[bot]
9d3498f01e
Translate subsurface_source.ts in nl_NL
100% translated source file: 'subsurface_source.ts'
on 'nl_NL'.
2024-02-29 19:58:56 +00:00
transifex-integration[bot]
afcff5da2b
Translate subsurface_source.ts in nl_NL
100% translated source file: 'subsurface_source.ts'
on 'nl_NL'.
2024-02-29 19:57:24 +00:00
transifex-integration[bot]
10d95531ff
Translate subsurface_source.ts in en_GB
100% translated source file: 'subsurface_source.ts'
on 'en_GB'.
2024-02-29 12:23:40 +00:00
Michael Keller
cedccbc340 Import: Update the libdivecomputer Submodule.
Update the libdivecomputer submodule.

Signed-off-by: Michael Keller <mikeller@042.ch>
2024-02-28 15:38:48 +13:00
Michael Keller
3ccd7e4bc7 Import: Add Support for New Dive Computer Models Supported by Libdivecomputer.
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>
2024-02-28 15:38:48 +13:00
Michael Keller
f495c4f002 Import: Update libdivecomputer to the Latest Version.
Update `libdivecomputer` to the latest upstream version.

Signed-off-by: Michael Keller <mikeller@042.ch>
2024-02-28 15:38:48 +13:00
Miika Turkia
4642f12e29 Divelogs.de integration update
Adding temp support for divelogs.de import/export.

Adding export of divecomputer model to divelogs.de export

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2024-02-27 15:44:32 -08:00
Michał Sawicz
c3aa505f2b snap: fix grade-setting
> variable 'grade' can be set only once.

Signed-off-by: Michał Sawicz <michal@sawicz.net>
2024-02-27 06:52:45 -08:00
Berthold Stoeger
bf5510e5a6 cleanup: remove bogus forward declaration of inexistent structure
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-02-27 13:14:34 +01:00
transifex-integration[bot]
8e023717f7
Translate subsurface_source.ts in de_DE
100% translated source file: 'subsurface_source.ts'
on 'de_DE'.
2024-02-24 22:09:16 +00:00
Dirk Hohndel
0cb5273766 Update translation source strings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2024-02-24 10:30:02 -08:00
transifex-integration[bot]
bca8eabcec Translate subsurface_source.ts in bg_BG
100% translated source file: 'subsurface_source.ts'
on 'bg_BG'.
2024-02-24 10:30:02 -08:00
transifex-integration[bot]
5ab5bc51cd Translate subsurface_source.ts in es_ES
100% translated source file: 'subsurface_source.ts'
on 'es_ES'.
2024-02-24 10:30:02 -08:00