From b10bbfeeecf2f368d2e869e5118982917a604572 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Mon, 14 Dec 2020 18:23:01 +0000 Subject: [PATCH] use correct precision when converting float/double values in QDomElement since exponent is allowed in XML according to the spec at https://www.w3.org/TR/xmlschema-2/ I prefer to use that but the limitation of std::strtod() is there - precision is lost when QString::toDouble() is used to convert the attribute back to double upstream commits: https://github.com/qt/qtbase/commit/8c883c8da32faf1245d257f1fc1fb39fb2b63efc https://github.com/qt/qtbase/commit/d7cb21ac085117f879a8aa1d7727b2ca52d3353d Signed-off-by: Ivailo Monev --- src/xml/dom/qdom.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index b3577d65a..6c11cf29e 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -4812,20 +4812,20 @@ void QDomElement::setAttribute(const QString& name, const QString& value) \fn void QDomElement::setAttribute(const QString& name, int value) \overload - The number is formatted according to the current locale. + The number is formatted according to the C locale. */ /*! \fn void QDomElement::setAttribute(const QString& name, uint value) \overload - The number is formatted according to the current locale. + The number is formatted according to the C locale. */ /*! \overload - The number is formatted according to the current locale. + The number is formatted according to the C locale. */ void QDomElement::setAttribute(const QString& name, qlonglong value) { @@ -4837,7 +4837,7 @@ void QDomElement::setAttribute(const QString& name, qlonglong value) /*! \overload - The number is formatted according to the current locale. + The number is formatted according to the C locale. */ void QDomElement::setAttribute(const QString& name, qulonglong value) { @@ -4849,25 +4849,25 @@ void QDomElement::setAttribute(const QString& name, qulonglong value) /*! \overload - The number is formatted according to the current locale. + The number is formatted according to the C locale. */ void QDomElement::setAttribute(const QString& name, float value) { if (!impl) return; - IMPL->setAttribute(name, QString::number(value)); + IMPL->setAttribute(name, QString::number(value, 'e')); } /*! \overload - The number is formatted according to the current locale. + The number is formatted according to the C locale. */ void QDomElement::setAttribute(const QString& name, double value) { if (!impl) return; - IMPL->setAttribute(name, QString::number(value)); + IMPL->setAttribute(name, QString::number(value, 'e')); } /*! @@ -5030,7 +5030,7 @@ void QDomElement::setAttributeNS(const QString& nsURI, const QString& qName, dou { if (!impl) return; - IMPL->setAttributeNS(nsURI, qName, QString::number(value)); + IMPL->setAttributeNS(nsURI, qName, QString::number(value, 'e')); } /*! -- 2.11.0