From 59e2becdd8041d92d3b3a98d36440494c975c845 Mon Sep 17 00:00:00 2001 From: Yuriy Skalko Date: Thu, 26 Nov 2020 22:10:45 +0200 Subject: [PATCH] Use iround function, amend c0ce79452f --- src/Row.cpp | 5 +++-- src/Spacing.cpp | 5 +++-- src/graphics/PreviewImage.cpp | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Row.cpp b/src/Row.cpp index 9ab7f11037..02923d1dd1 100644 --- a/src/Row.cpp +++ b/src/Row.cpp @@ -26,6 +26,7 @@ #include "support/debug.h" #include "support/lassert.h" #include "support/lstrings.h" +#include "support/lyxlib.h" #include #include @@ -297,7 +298,7 @@ int Row::left_x() const x += cit->full_width(); ++cit; } - return int(x + 0.5); + return support::iround(x); } @@ -313,7 +314,7 @@ int Row::right_x() const else break; } - return int(x + 0.5); + return support::iround(x); } diff --git a/src/Spacing.cpp b/src/Spacing.cpp index 9ac8345ab4..ce645398f8 100644 --- a/src/Spacing.cpp +++ b/src/Spacing.cpp @@ -12,8 +12,9 @@ #include #include "Spacing.h" -#include "support/lstrings.h" #include "support/convert.h" +#include "support/lstrings.h" +#include "support/lyxlib.h" #include @@ -55,7 +56,7 @@ void Spacing::set(Spacing::Space sp, string const & val) { space = sp; if (sp == Other) { - switch (int(convert(val) * 1000 + 0.5)) { + switch (support::iround(convert(val) * 1000)) { case 1000: space = Single; break; diff --git a/src/graphics/PreviewImage.cpp b/src/graphics/PreviewImage.cpp index 062dd6e7bc..b31af6fbd9 100644 --- a/src/graphics/PreviewImage.cpp +++ b/src/graphics/PreviewImage.cpp @@ -19,6 +19,7 @@ #include "PreviewLoader.h" #include "support/FileName.h" +#include "support/lyxlib.h" using namespace std; @@ -85,7 +86,7 @@ Dimension PreviewImage::dim() const if (!image) return dim; - dim.asc = int(pimpl_->ascent_frac_ * double(image->height()) + 0.5); + dim.asc = support::iround(pimpl_->ascent_frac_ * double(image->height())); dim.des = image->height() - dim.asc; dim.wid = image->width(); return dim;