Commit graph

20268 commits

Author SHA1 Message Date
Berthold Stoeger
177a1a6706 make format-warnings hard compile errors
Code such as `report_info("msg: %s", i)` may crash if `i` is
not a string type. To avoid such problems make format-warnings
hard compile errors.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
556ecd5a9b core: use C++-primitives for g_tag_list
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>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
b320942343 Replace remaining qDebug()s by report_info()
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>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
8867edffe8 Replace qDebug() by report_info() in profilewidget2.cpp
Remove those that are commented out, since this part of the code
will not be ported to QtQuick. So why bother?

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
991b72d4ff Replace qDebug() by report_info() in core/cloudstorage.cpp
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
47254d91e0 Replace qDebug() by report_info() in qt-init.cpp
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
9923d49624 Replace qDebug() by report_info in qthelper.cpp
To do so replace QStrings by std::strings in ui-language code.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
9febfdd084 Remove diabled debugging output in subsurfacewebservices.cpp
Why bother with commented out code?

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
8677d1f325 Replace qDebug() by report_info() in downloadfromdcthread.cpp
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
6dd5ec296d Convert qDebug() to report_info() in testing code
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
4de109bbf1 Replace qDebug() by report_info() in bluetooth code
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
d83da05f8d Replace qDebug() by report_info in checkcloudconnection.cpp
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
b6439e0420 Replace qDebug() by report_info() in smtk-import
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
ab7218d543 Use report_info() instead of qDebug in mobile code
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
2c2ad1e5c9 user report_info() instead of qDebug in main() functions
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
4af2ec88bd Use std::vector<string> instead of QStringList in main()
In an effort to convert core to C++ structures.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
c6cd10a43f core: make getCloudURL() return an std::string
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>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
8e106b0449 core: replace qDebug() by report_info() in subsurface-helper.cpp
Start unifying debug output.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
da7ea17b66 cleanup: replace fprintf to stderr by report_info()
Let's try to unify debugging output!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
b097c0a44f core: port errorhelper.c to C++
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>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
ec0bc2d06c cleanup: replace MIN and MAX macrors by standard versions
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>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
b89029353f import: use C++ primitives in smartrak.cpp
Makes memory management more palatable.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
14cfb17c1a import: compile smartrak.cpp as C++
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
157b52aa6e tests: make git-storage test more robust
The code was crashing if it couldn't reach the cloud, because then
info.repo is NULL. Skip the test if that happens.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
322c3b55e6 core: add compile time format check to format_string_std
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>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
a123589efb core: convert git_info to std::string
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>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
ae299d5e66 profile: use C++ string functions to format plot data
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>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
422f693f5b core: port tag.c to C++
Let taglist_get_tagstring() return an std::string, since all callers
are C++ anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
84b7ffafd2 core: use C++ versions of membuffer in add_to_string
Avoid explicit calls to free().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
e65ba50c1a core: use C++ constructs in save-html.cpp
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>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
82ba236859 core: port save-html.c to C++
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
177b03958c core: port worldmap-save.c to C++
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
bd3f9b107e planner: turn TIMESTEP macro into integer constant
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
15b17a0aca planner: turn error argument of add_plan_to_notes() into a boolean flag
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>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
b542a39a00 planner: turn UNIT_FACTOR macro into function
No apparent reason why this is a hard-to-read macro.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
9a052cd089 planner: move decotimestap to diveplannermodel.cpp
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>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
4db19d6284 planner: use std::string in plannernotes.cpp
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
8b51ff7ded core: add locale aware formatting function to std::string
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>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
fe68870079 planner: use std::vector instead of malloc() in planner.cpp
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
f69686d429 planner: encapsulate deco state cache in a struct
Removes memory management pain: the struct cleans up when it
goes out of scope.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
77e8c3655e core: compile planner source files with C++
Another relatively easily converted part of the code.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
jme
bd31efa821 Update downloadfromdivecomputer.cpp
Remove lines setting "current" computer to computer1.  

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-22 16:52:19 +12:00
jme
80eff1d6e2 Update downloadfromdivecomputer.ui
Per suggestion, use QFrame and trashcan icon.

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-22 16:52:19 +12:00
jme
74b1648fcc Update downloadfromdivecomputer.h
Change DDC<n> to DeleteDC<n>

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-22 16:52:19 +12:00
jme
7fb0e9e59e Update downloadfromdivecomputer.cpp
Changed DDC<n> to DeleteDC<n> and hide set visibility for new Qframe

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-22 16:52:19 +12:00
jme
d59bd1831a Update downloadfromdivecomputer.cpp
Added delete dive computer buttons.

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-22 16:52:19 +12:00
jme
f05808fded Update downloadfromdivecomputer.h
Added delete dive computer buttons.

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-22 16:52:19 +12:00
jme
1692e48163 Update downloadfromdivecomputer.ui
Added delete dive computer buttons.

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-22 16:52:19 +12:00
Michael Keller
375b08857c Desktop: Remove Unneeded Special Case for MacOS.
Since the removal of this special case for MacOS was confirmed to be
working in the case of building with bluetooth support in #4120, we should
probably remove it from the code used when building without bluetooth
support as well.

Signed-off-by: Michael Keller <mikeller@042.ch>
2024-04-21 13:13:18 +12:00
Michael Keller
d49092ac70 CICD: Add Script to Find the Changeset ID for a CICD Release Number.
Add a script that finds the changeset ID in the subsurface repository
that a given CICD release was built from.
The option '-c' can be used to check out the changeset, if one is found.

Signed-off-by: Michael Keller <mikeller@042.ch>
2024-04-20 10:46:28 +07:00