summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/qml/qmlobjectscriptclass.cpp2
-rw-r--r--tests/auto/declarative/qmlecmascript/data/extendedObjectPropertyLookup.qml8
-rw-r--r--tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp15
3 files changed, 24 insertions, 1 deletions
diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp
index 84470fc..d3a2a22 100644
--- a/src/declarative/qml/qmlobjectscriptclass.cpp
+++ b/src/declarative/qml/qmlobjectscriptclass.cpp
@@ -132,7 +132,7 @@ QmlObjectScriptClass::queryProperty(QObject *obj, const Identifier &name,
cache = ddata->propertyCache;
if (!cache) {
cache = enginePrivate->cache(obj);
- if (ddata) { cache->addref(); ddata->propertyCache = cache; }
+ if (cache && ddata) { cache->addref(); ddata->propertyCache = cache; }
}
if (cache) {
diff --git a/tests/auto/declarative/qmlecmascript/data/extendedObjectPropertyLookup.qml b/tests/auto/declarative/qmlecmascript/data/extendedObjectPropertyLookup.qml
new file mode 100644
index 0000000..8ff3aeb
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/extendedObjectPropertyLookup.qml
@@ -0,0 +1,8 @@
+import Qt.test 1.0
+import Qt 4.6
+
+Object {
+ property MyExtendedObject a;
+ a: MyExtendedObject { id: Root }
+ property int b: Math.max(Root.extendedProperty, 0)
+}
diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
index 6bc88c0..dde3bb7 100644
--- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
+++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
@@ -60,6 +60,7 @@ private slots:
void dynamicDestruction();
void objectToString();
void selfDeletingBinding();
+ void extendedObjectPropertyLookup();
private:
QmlEngine engine;
@@ -709,6 +710,20 @@ void tst_qmlecmascript::selfDeletingBinding()
}
}
+/*
+Test that extended object properties can be accessed.
+
+This test a regression where this used to crash. The issue was specificially
+for extended objects that did not include a synthesized meta object (so non-root
+and no synthesiszed properties).
+*/
+void tst_qmlecmascript::extendedObjectPropertyLookup()
+{
+ QmlComponent component(&engine, TEST_FILE("extendedObjectPropertyLookup.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
QTEST_MAIN(tst_qmlecmascript)
#include "tst_qmlecmascript.moc"