aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlpropertymap
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-01-02 12:17:31 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-02 23:36:58 +0100
commitbf3dfe64068d76f98a2176530e1158d5143e09b2 (patch)
treec50c3f52bef636474e851c010b0fff0e0eb936b3 /tests/auto/qml/qqmlpropertymap
parenteb3087e4b0b770200512925730c328a8bda7f3d7 (diff)
Fix property access to QQmlPropertyMap objects when addressed via id
Property access to id objects is optimized at compile time, but we cannot do that for QQmlPropertyMap instances (or generally fully dynamic types). This issue was a regression against Qt 5.1 Task-number: QTBUG-35906 Change-Id: I759a1a899f6a3a1f6466282f455b289ad7451086 Reviewed-by: Albert Astals Cid <albert.astals@canonical.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests/auto/qml/qqmlpropertymap')
-rw-r--r--tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp
index 17f54508a3..62b64a3ef1 100644
--- a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp
+++ b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp
@@ -72,6 +72,7 @@ private slots:
void QTBUG_29836();
void QTBUG_35233();
void disallowExtending();
+ void QTBUG_35906();
};
class LazyPropertyMap : public QQmlPropertyMap, public QQmlParserStatus
@@ -79,7 +80,7 @@ class LazyPropertyMap : public QQmlPropertyMap, public QQmlParserStatus
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
- Q_PROPERTY(int someFixedProperty READ someFixedProperty WRITE setSomeFixedProperty)
+ Q_PROPERTY(int someFixedProperty READ someFixedProperty WRITE setSomeFixedProperty NOTIFY someFixedPropertyChanged)
public:
LazyPropertyMap()
: QQmlPropertyMap(this, /*parent*/0)
@@ -92,7 +93,10 @@ public:
}
int someFixedProperty() const { return value; }
- void setSomeFixedProperty(int v) { value = v; }
+ void setSomeFixedProperty(int v) { value = v; emit someFixedPropertyChanged(); }
+
+signals:
+ void someFixedPropertyChanged();
private:
int value;
@@ -450,6 +454,27 @@ void tst_QQmlPropertyMap::disallowExtending()
QCOMPARE(component.errors().at(0).toString(), QStringLiteral("<Unknown File>: Fully dynamic types cannot declare new properties."));
}
+void tst_QQmlPropertyMap::QTBUG_35906()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQml 2.0\n"
+ "import QTBUG_35233 1.0\n"
+ "QtObject {\n"
+ " property int testValue: mapById.someFixedProperty\n"
+ "\n"
+ " property QtObject maProperty: LazyPropertyMap {\n"
+ " id: mapById\n"
+ " someFixedProperty: 42\n"
+ " }\n"
+ "}\n", QUrl());
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(!obj.isNull());
+ QVariant value = obj->property("testValue");
+ QVERIFY(value.type() == QVariant::Int);
+ QCOMPARE(value.toInt(), 42);
+}
+
QTEST_MAIN(tst_QQmlPropertyMap)
#include "tst_qqmlpropertymap.moc"