[LyX/master] Use iround function, amend c0ce79452f

Yuriy Skalko yuriy.skalko at gmail.com
Fri Nov 27 09:47:44 UTC 2020


commit 59e2becdd8041d92d3b3a98d36440494c975c845
Author: Yuriy Skalko <yuriy.skalko at gmail.com>
Date:   Thu Nov 26 22:10:45 2020 +0200

    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 9ab7f11..02923d1 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 <algorithm>
 #include <ostream>
@@ -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 9ac8345..ce64539 100644
--- a/src/Spacing.cpp
+++ b/src/Spacing.cpp
@@ -12,8 +12,9 @@
 #include <config.h>
 
 #include "Spacing.h"
-#include "support/lstrings.h"
 #include "support/convert.h"
+#include "support/lstrings.h"
+#include "support/lyxlib.h"
 
 #include <ostream>
 
@@ -55,7 +56,7 @@ void Spacing::set(Spacing::Space sp, string const & val)
 {
 	space = sp;
 	if (sp == Other) {
-		switch (int(convert<double>(val) * 1000 + 0.5)) {
+		switch (support::iround(convert<double>(val) * 1000)) {
 		case 1000:
 			space = Single;
 			break;
diff --git a/src/graphics/PreviewImage.cpp b/src/graphics/PreviewImage.cpp
index 062dd6e..b31af6f 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;


More information about the lyx-cvs mailing list