Internal floating point (FP) calculations should be performed using double
unless there is a very good reason. This avoids headaches with conversions.
Indeed, the vast majority of FP calculations were already done using double.
This patch adapts most remaining calculations. Not converted where things
that were based on binary representations and variables which weren't used
anyway.
An analysis of all instances follows:
core/plannernotes.c, l.404:
This was a comparison between two floats. On the left side, first an integer
was cast to float then multiplied with and integer and divided by a constant
double. The right hand side was an integer cast to a float. Simply divide by
1000.0 first to convert to double and continue with calculations. On the right
hand side, remove the cast, because the integer will be implicitely cast to
double for comparison. This conversion actually emits less instructions,
because no conversion to double and back is performed.
core/planner.c, l.613:
Same analysis as previous case.
subsurface-desktop-main.cpp, l.155:
A local variable representing the version OpenGL version. Turn this into
integer logic. Not only does this avoid dreaded FP rounding issues, it also
works correctly for minor version > 10 (not that such a thing is to be
expected anytime soon).
abstractpreferenceswidget.[h/cpp]:
A widget where the position is described as a float. Turn into double.
desktop-widgets/divelogexportdialog.cpp, l.313:
total_weight is described as float. Use double arithmetics instead. This
instance fixes a truncation warning emitted by gcc.
The Windows auto-verbose + log file creation if starting
from a non-terminal has the problem that the print_version()
call is never made becase 'verbose' is updated programatically
in windows.c and not by the user (by passing -v).
To work around the issue:
- move the windows console creation call before *everything* else
- then immediatelly install the message handler
- then see if 'verbose' is set and explicitly call print_version()
print_version() now also has a flag (version_printed), to avoid
printing the version multiple times, if the user decided to add
an extra -v to the Desktop shortcut.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Currently one has to explicitly use --win32console and/or
--win32log to enable a dedicated console (a console window
that opens next to the Subsurface window) or to enable file
logging on Win32.
This patch makes the following changes:
- removes the --win32* command line arguments
- removes the dedicated console window support
- if the app starts from a shortcut and not from a console, always
redirect stderr and stdout to _err & _out log files
- if the app starts from a console redirect stderr and stdout to that
console
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
When verMinor is extracted with the glGetString() method,
use roundf() to round the GL MINOR version to an integer.
2.1 is split in 2 and 1.
Without this patch rounding issues are present as for 32bit IEEE
the default rounding makes (0.1f * 10.f) into 0.999999f.
Given the MINOR is a single digit for GL, calling roundf() on
0.999999 gives the expected result 1 for the MINOR.
Reported-by: Murillo Fernandes Bernardes <notifications@github.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
First, attempt to use glGetString(GL_VERSION), which works
on legacy profiles but has to be parsed (unsafe and vendor specific?).
If the above fails attempt to use the newer version API from
glGetIntegerv().
If both fail, fall back to a software renderer or exit.
If GLES is detected from glGetString() (for some odd reason -
e.g. emulated driver) show a warning and return early as we don't
handle it's versioning.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Without this patch the user can pass a custom backend
like 'software' and the validation will still be performed.
In a case where the validation fails Subsurface will still exit.
With this patch the validation is performed *only* for the
standard backend which is OpenGL (or an empty QT_QUICK_BACKEND)
env. variable.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Add a new static function to validate the availability of OpenGL
on this particular desktop system. It makes some calls to create
a platform agnostic GL context that renders to a offscreen surface.
Then it makes a couple of glGetIntegerv((GL_xxx_VERSION, ...) calls
to see if the GL profile version is at least 2.1.
In case any of the steps fail, a stderr message is shown and all
QtQuick based widgets would be rendered using a software renderer.
Testing was done in the case of the Google maps plugin and the
fallback seems to work on Windows, but further testing will be
required on all OS.
For the time being, the automatic fallback is only supported
on Qt 5.8.0 or later.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
We only do this in verbose mode to make sure a report contains the information
about the existing files used.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
report_error() now does this automatically. So all these odd places in which we tried
to make sure that we show errors are no longer needed.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
fill_computer_list() creates a Qt friendly
structure that contains all of the necessary
information about dive computers and it's
devices, and it's needed both in Qml and Widgets
to allow the user to download their dives.
This patch makes it possible to use the code
in QML without duplication.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Maintab is one of our most complex classes, and it's
something I'm not actually proud of. But it currently
works and the idea of splitting it was in my head for
quite a while.
This is the third or fourth tentative of splitting it,
and this time I let the most complex part of it untouched,
the Notes and Equipment tab are way too complex to untangle
right now on my limited time.
A new class 'TabBase' should be used for any new tab that
we may create, and added on the MainTab (see the new lines
on the MainTab constructor).
Also, Extra Info, Information, Photos and Statistics where
ported to this new way helping reduce the number of
lines and functions on the MainTab quite a bit.
Overall this is a step in the right direction for the future.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Adding --win32log as the first command line option on Windows
will now log all stdout and stderr output to the files
subsurface_err.log and subsurface_out.log in the working directory.
This change required a new argument 'bool logfile' to be added to:
subsurface_console_init() which is defined in all platform files
(linux.c, macos.c, etc.)
Example usage:
subsurface.exe --win32log -v -v -v
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
No point in having it defined in each main program's .cpp. Especially
since the unit tests don't define them.
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Having subsurface-core as a directory name really messes with
autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an
autocomplete conflict and also was inconsistent with the desktop-widget
name for the directory containing the "other" UI.
And while cleaning up the resulting change in the path name for include
files, I decided to clean up those even more to make them consistent
overall.
This could have been handled in more commits, but since this requires a
make clean before the build, it seemed more sensible to do it all in one.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Some users try to run Subsurface as root for example to get around
permission problems with dive computer devices. This is a bad idea
since config files get touched as root and then cannot be read
as normal user anymore.
This patch allows running as root only with verbose option on. We can
assume if somebody manages to start subsurface as root this happens
from the command line.
For some reason, I couldn't get translation working at this stage.
Windows version is a stub.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We use random numbers for file names, both temporary filename when
creating a zip for divelogs.de upload and for filename on form data for
facebook upload. This does not require for true randomness but we still
want these to not be constant on each run of Subsurface. Thus we need to
initialize the random number generator.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
start of the QSettinsg Object Wrapper usage on the code
this first patch removes two macros that generated around
200 lines in runtime for something like a quarter of it
Basically, whenever we changed anything we called the
PreferencesDialog::settingsChanged and connected everythign
to that signal, now each setting has it's own changed signal
and we can call it directly.
The best thing about this approach is that we don't trigger
repaints for things that are not directly profile related. (
actually we still do, but the plan is to remove them in due time)
this commit breaks correct atualization of the profile (because
everything was connected to PreferencesDialog::settingsChanged)
and now I need to hunt a bit for the correct connections
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
And action can't not just trigger a slot, it can also send a signal.
With this there is no reference to the MainWindow left in the profile.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead of directly calling into the MainWindow, redirect this via a
signal so Subsurface mobile can hook it up as needed.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I'm not sure we can ever run into this issue anymore since we stop
calculating TTS / NDL past 2 hours, but I guess on a fairly slow CPU this
still could take too long.
But instead of calling into MainWindow let's just change the setting right
here and add a signal to show the notification - that way we can use the
appropriate way to make such notifications on the mobile app.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is needed to compile both in a single call to make. Also it will
help removing some of the mistakes in the current android version:
it always created the mainwindow, even without using it for anything,
so tons of memory will be freed now for the android version, making it
snappier and smoother.
This is a necessary move so we don't need to #ifdef all over the place
for the two different versions, and imo the changes needed to keep both
versions will not be that huge if we keep things in subsurface-core
sane.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>