diff options
5 files changed, 41 insertions, 3 deletions
diff --git a/examples/declarative/aspectratio/face_fit_animated.qml b/examples/declarative/aspectratio/face_fit_animated.qml index 7d73900..9d63e69 100644 --- a/examples/declarative/aspectratio/face_fit_animated.qml +++ b/examples/declarative/aspectratio/face_fit_animated.qml @@ -17,8 +17,8 @@ Rectangle { x: (parent.width-width*scale)/2 y: (parent.height-height*scale)/2 scale: SpringFollow { - source: Math.max(Math.min(Image.parent.width/Image.width*1.333,Image.parent.height/Image.height), - Math.min(Image.parent.width/Image.width,Image.parent.height/Image.height*1.333)) + source: Math.max(Math.min(Face.parent.width/Face.width*1.333,Face.parent.height/Face.height), + Math.min(Face.parent.width/Face.width,Face.parent.height/Face.height*1.333)) spring: 1 damping: 0.05 } diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index a58b35e..72603ed 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -1255,7 +1255,8 @@ QmlTypeNameScriptClass::queryProperty(const QScriptValue &scriptObject, } else { // Must be an attached property this->object = qmlAttachedPropertiesObjectById(bridge.type->index(), bridge.object); - Q_ASSERT(this->object); + if (!this->object) + return 0; return ep->queryObject(strName, id, this->object); } } diff --git a/tests/auto/declarative/qmlecmascript/data/enums.2.qml b/tests/auto/declarative/qmlecmascript/data/enums.2.qml new file mode 100644 index 0000000..bdc672f --- /dev/null +++ b/tests/auto/declarative/qmlecmascript/data/enums.2.qml @@ -0,0 +1,8 @@ +import Qt.test 1.0 +import Qt.test 1.0 as Namespace + +MyQmlObject { + property int a: MyQmlObject.EnumValue10 + property int b: Namespace.MyQmlObject.EnumValue10 +} + diff --git a/tests/auto/declarative/qmlecmascript/data/nonExistantAttachedObject.qml b/tests/auto/declarative/qmlecmascript/data/nonExistantAttachedObject.qml new file mode 100644 index 0000000..f9585db --- /dev/null +++ b/tests/auto/declarative/qmlecmascript/data/nonExistantAttachedObject.qml @@ -0,0 +1,5 @@ +import Qt.test 1.0 + +MyQmlObject { + stringProperty: MyQmlContainer.prop +} diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp index f01e9d4..7e6d83b 100644 --- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp +++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp @@ -48,6 +48,7 @@ private slots: void valueTypeFunctions(); void constantsOverrideBindings(); void outerBindingOverridesInnerBinding(); + void nonExistantAttachedObject(); private: QmlEngine engine; @@ -378,6 +379,8 @@ void tst_qmlecmascript::extensionObjects() void tst_qmlecmascript::enums() { + // Existant enums + { QmlComponent component(&engine, TEST_FILE("enums.1.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -392,6 +395,15 @@ void tst_qmlecmascript::enums() QCOMPARE(object->property("h").toInt(), 3); QCOMPARE(object->property("i").toInt(), 19); QCOMPARE(object->property("j").toInt(), 19); + } + // Non-existant enums + { + QmlComponent component(&engine, TEST_FILE("enums.2.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("a").toInt(), 0); + QCOMPARE(object->property("b").toInt(), 0); + } } void tst_qmlecmascript::valueTypeFunctions() @@ -482,6 +494,18 @@ void tst_qmlecmascript::outerBindingOverridesInnerBinding() QCOMPARE(object->property("c3").toInt(), 8); } +/* +Access a non-existant attached object. + +Tests for a regression where this used to crash. +*/ +void tst_qmlecmascript::nonExistantAttachedObject() +{ + QmlComponent component(&engine, TEST_FILE("nonExistantAttachedObject.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); +} + QTEST_MAIN(tst_qmlecmascript) #include "tst_qmlecmascript.moc" |