From 1f8e66b71bc641a9e29f3b3157de2d393d911f23 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 30 Nov 2009 09:53:03 +1000 Subject: Fix and test ListModel UTF8 reading. --- src/declarative/util/qmllistmodel.cpp | 2 +- tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index 5491fd7..8259dcd 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -851,7 +851,7 @@ void QmlListModelParser::setCustomData(QObject *obj, const QByteArray &d) case ListInstruction::Value: { ModelNode *n = nodes.top(); - n->values.append(QByteArray(data + instr.dataIdx)); + n->values.append(QString::fromUtf8(QByteArray(data + instr.dataIdx))); } break; diff --git a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp index f2ffb7b..c7de5d9 100644 --- a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp +++ b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp @@ -51,12 +51,26 @@ public: tst_QmlListModel() {} private slots: + void static_i18n(); void dynamic_data(); void dynamic(); void error_data(); void error(); }; +void tst_QmlListModel::static_i18n() +{ + QString expect = QString::fromUtf8("na\303\257ve"); + QString componentStr = "import Qt 4.6\nListModel { ListElement { prop1: \""+expect+"\" } }"; + QmlEngine engine; + QmlComponent component(&engine, componentStr.toUtf8(), QUrl("file://")); + QmlListModel *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QString prop = obj->get(0).property(QLatin1String("prop1")).toString(); + QCOMPARE(prop,expect); + delete obj; +} + void tst_QmlListModel::dynamic_data() { QTest::addColumn("script"); -- cgit v0.12