summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFlorian Hänel <florian.haenel@basyskom.com>2012-03-15 16:18:34 +0100
committerQt by Nokia <qt-info@nokia.com>2012-07-24 05:18:56 +0200
commit32ace476d08bad2397026f8d70f6e534ef366aa8 (patch)
tree8b42f745b47a9c104b17eea59fcef19f656b8845 /src
parented3fd81309130caa38543a5d31b23ae71f859ec5 (diff)
remove double-string-double conversion from QDeclarativeListModel
we do a double-string-double conversion in QDeclarativeListModel which introduces precision errors if that conversion is lossy, e.g. ecvt. is used Change-Id: Ie871ebbb04695f56fc7b49b9d788037da4a857c0 Reviewed-by: Glenn Watson <glenn.watson@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/declarative/util/qdeclarativelistmodel.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp
index 94275311..14de5f63 100644
--- a/src/declarative/util/qdeclarativelistmodel.cpp
+++ b/src/declarative/util/qdeclarativelistmodel.cpp
@@ -707,7 +707,8 @@ bool QDeclarativeListModelParser::compileProperty(const QDeclarativeCustomParser
if (variant.isString()) {
d += variant.asString().toUtf8();
} else if (variant.isNumber()) {
- d += QByteArray::number(variant.asNumber(),'g',20);
+ double temp = variant.asNumber();
+ d += QByteArray( reinterpret_cast<const char*>(&temp), sizeof(double));
} else if (variant.isBoolean()) {
d += char(variant.asBoolean());
} else if (variant.isScript()) {
@@ -726,7 +727,8 @@ bool QDeclarativeListModelParser::compileProperty(const QDeclarativeCustomParser
}
} else {
d[0] = char(QDeclarativeParser::Variant::Number);
- d += QByteArray::number(v);
+ double temp = v;
+ d += QByteArray( reinterpret_cast<const char*>(&temp), sizeof(double));
}
}
}
@@ -782,7 +784,6 @@ QByteArray QDeclarativeListModelParser::compile(const QList<QDeclarativeCustomPa
void QDeclarativeListModelParser::setCustomData(QObject *obj, const QByteArray &d)
{
QDeclarativeListModel *rv = static_cast<QDeclarativeListModel *>(obj);
-
ModelNode *root = new ModelNode(rv->m_nested);
rv->m_nested->m_ownsRoot = true;
rv->m_nested->_root = root;
@@ -824,7 +825,9 @@ void QDeclarativeListModelParser::setCustomData(QObject *obj, const QByteArray &
n->values.append(bool(data[1 + instr.dataIdx]));
break;
case QDeclarativeParser::Variant::Number:
- n->values.append(QByteArray(data + 1 + instr.dataIdx).toDouble());
+ double temp;
+ ::memcpy(&temp, data + 1 + instr.dataIdx, sizeof(double));
+ n->values.append(temp);
break;
case QDeclarativeParser::Variant::String:
n->values.append(QString::fromUtf8(data + 1 + instr.dataIdx));