aboutsummaryrefslogtreecommitdiffstats
path: root/profile-widget/divecartesianaxis.cpp
diff options
context:
space:
mode:
authorGravatar Jeremie Guichard <djebrest@gmail.com>2017-03-23 08:13:49 +0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-03-24 09:39:25 -0700
commit597539ce39ab1054851f5aa96daa0fff29699e8f (patch)
tree281045e31b92d9952055c954a45883dcb8e02ca3 /profile-widget/divecartesianaxis.cpp
parentd83449f3b56c5dbdfbe0f8e5ae908179ba1d6419 (diff)
downloadsubsurface-597539ce39ab1054851f5aa96daa0fff29699e8f.tar.gz
Fix double to int truncation in C++ code
Wfloat-conversion enabled for C++ part of the code Fix warnings raised by the flag using lrint Original issue reported on the mailing list: The ascent/descent rates are sometimes not what is expected. E.g. setting the ascent rate to 10m/min results in an actual ascent rate of 9m/min. This is due to truncating the ascent rate preference, then effectively rounding up the time to reach each stop to 2s intervals. The result being that setting the ascent rate to 10m/min results in 20s to ascend 3m (9m/min), when it should be exactly 18s. Reported-by: John Smith <noseygit@hotmail.com> Reported-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
Diffstat (limited to 'profile-widget/divecartesianaxis.cpp')
-rw-r--r--profile-widget/divecartesianaxis.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/profile-widget/divecartesianaxis.cpp b/profile-widget/divecartesianaxis.cpp
index 4270d4b89..df27f90d4 100644
--- a/profile-widget/divecartesianaxis.cpp
+++ b/profile-widget/divecartesianaxis.cpp
@@ -369,7 +369,7 @@ QString DepthAxis::textForValue(double value)
{
if (value == 0)
return QString();
- return get_depth_string(value, false, false);
+ return get_depth_string(lrint(value), false, false);
}
QColor DepthAxis::colorForValue(double value)
@@ -409,7 +409,7 @@ QColor TimeAxis::colorForValue(double value)
QString TimeAxis::textForValue(double value)
{
- int nr = value / 60;
+ int nr = lrint(value) / 60;
if (maximum() < 600)
return QString("%1:%2").arg(nr).arg((int)value % 60, 2, 10, QChar('0'));
return QString::number(nr);