From 68a662a2e15b790080ea12c2434f6e1fe60bda1b Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Sat, 26 Apr 2014 14:42:39 +0200 Subject: Fix translations in states causing failing assertions This is a smaller fix suitable for the release branch, merely adding support for translations to the bytearray compilation step for states and ensuring a consistent error message when qsTr is used in list models. The proper fix will be done in dev that eliminates the entire intermediate QByteArray storage for custom compilers. Task-number: QTBUG-38492 Change-Id: If5171f16eb742c718e48b8bbcb265b0c241cd5e7 Reviewed-by: Lars Knoll --- tests/auto/quick/qquickstates/data/QTBUG-38492.qml | 16 ++++++++++++++++ tests/auto/quick/qquickstates/tst_qquickstates.cpp | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 tests/auto/quick/qquickstates/data/QTBUG-38492.qml (limited to 'tests/auto/quick') diff --git a/tests/auto/quick/qquickstates/data/QTBUG-38492.qml b/tests/auto/quick/qquickstates/data/QTBUG-38492.qml new file mode 100644 index 0000000000..d6d6d81fd3 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/QTBUG-38492.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +Item { + id: root + property string text; + + states: [ + State { + name: 'apply' + PropertyChanges { + target: root + text: qsTr("Test") + } + } + ] +} diff --git a/tests/auto/quick/qquickstates/tst_qquickstates.cpp b/tests/auto/quick/qquickstates/tst_qquickstates.cpp index 0c9b75636f..6b46ab1fae 100644 --- a/tests/auto/quick/qquickstates/tst_qquickstates.cpp +++ b/tests/auto/quick/qquickstates/tst_qquickstates.cpp @@ -148,6 +148,7 @@ private slots: void QTBUG_14830(); void avoidFastForward(); void revertListBug(); + void QTBUG_38492(); }; void tst_qquickstates::initTestCase() @@ -1626,6 +1627,21 @@ void tst_qquickstates::revertListBug() QCOMPARE(rect2->parentItem(), origParent2); //QTBUG-22583 causes rect2's parent item to be origParent1 } +void tst_qquickstates::QTBUG_38492() +{ + QQmlEngine engine; + + QQmlComponent rectComponent(&engine, testFileUrl("QTBUG-38492.qml")); + QQuickItem *item = qobject_cast(rectComponent.create()); + QVERIFY(item != 0); + + QQuickItemPrivate::get(item)->setState("apply"); + + QCOMPARE(item->property("text").toString(), QString("Test")); + + delete item; +} + QTEST_MAIN(tst_qquickstates) #include "tst_qquickstates.moc" -- cgit v1.2.1