From 8c883c8da32faf1245d257f1fc1fb39fb2b63efc Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Wed, 19 Feb 2020 18:48:32 +0100 Subject: QDom: use correct precision when converting float/double values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit d7cb21ac085117f879a8aa1d7727b2ca52d3353d change the way a double is converted which resulted in less precision. Fix it by explictily setting the precision in QString::setNum() Task-number: QTBUG-80068 Change-Id: I1fd9d00837155ceb707e84bfeb9deff03b5ab57e Reviewed-by: André Hartmann Reviewed-by: Konstantin Shegunov Reviewed-by: Lars Knoll --- src/xml/dom/qdom.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/xml/dom/qdom.cpp') diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index 04151c3f31..04331527f9 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -62,6 +62,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -4866,7 +4867,7 @@ void QDomElement::setAttribute(const QString& name, float value) if (!impl) return; QString x; - x.setNum(value); + x.setNum(value, 'g', 8); IMPL->setAttribute(name, x); } @@ -4880,7 +4881,7 @@ void QDomElement::setAttribute(const QString& name, double value) if (!impl) return; QString x; - x.setNum(value); + x.setNum(value, 'g', 17); IMPL->setAttribute(name, x); } @@ -5049,7 +5050,7 @@ void QDomElement::setAttributeNS(const QString nsURI, const QString& qName, doub if (!impl) return; QString x; - x.setNum(value); + x.setNum(value, 'g', 17); IMPL->setAttributeNS(nsURI, qName, x); } -- cgit v1.2.3