summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-11-15 21:46:32 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-11-19 17:33:33 +0100
commitd7cb21ac085117f879a8aa1d7727b2ca52d3353d (patch)
treec03c3e62de3011d7743459078a7978206674190f /src
parentede867f581c0894e13d669f5364610df7ade0eb5 (diff)
QDom: use QLocale::C when converting a double to a xml attribute
QDomElement::setAttribute(QString, double) did not use QString::setNum() but qsnprintf(). This is wrong because qsnprintf() is using the current locale instead QLocale::C. It was also inconsistent to QDomElement::setAttributeNS() which was already using QString::setNum(). Also fix the documentation which stated that all QDomElement::setAttribute() format the values according the current locale. Fixes: QTBUG-80068 Change-Id: Iabb0b39c0d0723060527542c283a5435f26f31ca Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/xml/dom/qdom.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp
index 8d232237bf..04151c3f31 100644
--- a/src/xml/dom/qdom.cpp
+++ b/src/xml/dom/qdom.cpp
@@ -4818,20 +4818,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 formatting always uses QLocale::C.
*/
/*!
\fn void QDomElement::setAttribute(const QString& name, uint value)
\overload
- The number is formatted according to the current locale.
+ The formatting always uses QLocale::C.
*/
/*!
\overload
- The number is formatted according to the current locale.
+ The formatting always uses QLocale::C.
*/
void QDomElement::setAttribute(const QString& name, qlonglong value)
{
@@ -4845,7 +4845,7 @@ void QDomElement::setAttribute(const QString& name, qlonglong value)
/*!
\overload
- The number is formatted according to the current locale.
+ The formatting always uses QLocale::C.
*/
void QDomElement::setAttribute(const QString& name, qulonglong value)
{
@@ -4859,7 +4859,7 @@ void QDomElement::setAttribute(const QString& name, qulonglong value)
/*!
\overload
- The number is formatted according to the current locale.
+ The formatting always uses QLocale::C.
*/
void QDomElement::setAttribute(const QString& name, float value)
{
@@ -4873,19 +4873,14 @@ void QDomElement::setAttribute(const QString& name, float value)
/*!
\overload
- The number is formatted according to the current locale.
+ The formatting always uses QLocale::C.
*/
void QDomElement::setAttribute(const QString& name, double value)
{
if (!impl)
return;
QString x;
- char buf[256];
- int count = qsnprintf(buf, sizeof(buf), "%.16g", value);
- if (count > 0)
- x = QString::fromLatin1(buf, count);
- else
- x.setNum(value); // Fallback
+ x.setNum(value);
IMPL->setAttribute(name, x);
}