From 597539ce39ab1054851f5aa96daa0fff29699e8f Mon Sep 17 00:00:00 2001 From: Jeremie Guichard Date: Thu, 23 Mar 2017 08:13:49 +0700 Subject: 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 Reported-by: Rick Walsh Signed-off-by: Jeremie Guichard --- desktop-widgets/mainwindow.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'desktop-widgets/mainwindow.cpp') diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index b6faa3dff..28bc6cee6 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -1041,8 +1041,8 @@ void MainWindow::on_actionYearlyStatistics_triggered() QTreeView *view = new QTreeView(); view->setModel(m); l->addWidget(view); - d.resize(width() * .8, height() / 2); - d.move(width() * .1, height() / 4); + d.resize(lrint(width() * .8), height() / 2); + d.move(lrint(width() * .1), height() / 4); QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), &d); connect(close, SIGNAL(activated()), &d, SLOT(close())); QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), &d); @@ -1105,19 +1105,19 @@ void MainWindow::on_actionViewAll_triggered() const int appH = qApp->desktop()->size().height(); const int appW = qApp->desktop()->size().width(); if (mainSizes.empty()) { - mainSizes.append(appH * 0.7); - mainSizes.append(appH * 0.3); + mainSizes.append(lrint(appH * 0.7)); + mainSizes.append(lrint(appH * 0.3)); } static QList infoProfileSizes; if (infoProfileSizes.empty()) { - infoProfileSizes.append(appW * 0.3); - infoProfileSizes.append(appW * 0.7); + infoProfileSizes.append(lrint(appW * 0.3)); + infoProfileSizes.append(lrint(appW * 0.7)); } static QList listGlobeSizes; if (listGlobeSizes.empty()) { - listGlobeSizes.append(appW * 0.7); - listGlobeSizes.append(appW * 0.3); + listGlobeSizes.append(lrint(appW * 0.7)); + listGlobeSizes.append(lrint(appW * 0.3)); } QSettings settings; -- cgit v1.2.3-70-g09d2