diff options
-rw-r--r-- | demos/declarative/contacts/contacts.qml | 4 | ||||
-rw-r--r-- | examples/declarative/aspectratio/face_fit_animated.qml | 4 | ||||
-rw-r--r-- | examples/declarative/listview/highlight.qml | 4 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 3 | ||||
-rw-r--r-- | src/declarative/qml/qmlmetaproperty.cpp | 18 | ||||
-rw-r--r-- | src/declarative/qml/qmlmetaproperty_p.h | 6 | ||||
-rw-r--r-- | tests/auto/declarative/qmlecmascript/data/enums.2.qml | 8 | ||||
-rw-r--r-- | tests/auto/declarative/qmlecmascript/data/nonExistantAttachedObject.qml | 5 | ||||
-rw-r--r-- | tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp | 24 |
9 files changed, 64 insertions, 12 deletions
diff --git a/demos/declarative/contacts/contacts.qml b/demos/declarative/contacts/contacts.qml index 278eeb3..2b0d983 100644 --- a/demos/declarative/contacts/contacts.qml +++ b/demos/declarative/contacts/contacts.qml @@ -224,7 +224,7 @@ Rectangle { } } ] - autoHighlight: true + highlightFollowsCurrentItem: true focus: false } FocusScope { @@ -291,7 +291,7 @@ Rectangle { ] } focus: contacts.mode != 'new' - forwardTo: { contacts.mode == "list" ? [searchBarWrapper, contactListView] : [contactListView]} + Keys.forwardTo: { contacts.mode == "list" ? [searchBarWrapper, contactListView] : [contactListView]} states: [ State { name: "editNewState" 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/examples/declarative/listview/highlight.qml b/examples/declarative/listview/highlight.qml index cb92ad9..b6db453 100644 --- a/examples/declarative/listview/highlight.qml +++ b/examples/declarative/listview/highlight.qml @@ -37,7 +37,7 @@ Rectangle { ] } } - // Specify a highlight with custom movement. Note that autoHighlight + // Specify a highlight with custom movement. Note that highlightFollowsCurrentItem // is set to false in the ListView so that we can control how the // highlight moves to the current item. Component { @@ -51,7 +51,7 @@ Rectangle { id: List1 width: 200; height: parent.height model: MyPetsModel; delegate: PetDelegate - highlight: PetHighlight; autoHighlight: false + highlight: PetHighlight; highlightFollowsCurrentItem: false focus: true } } 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/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index 91769d3..efc4a2b 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -119,6 +119,7 @@ QmlMetaObjectCache::property(const QString &name, const QMetaObject *metaObject) QmlMetaProperty::QmlMetaProperty() : d(new QmlMetaPropertyPrivate) { + d->q = this; } /*! @@ -134,7 +135,9 @@ QmlMetaProperty::~QmlMetaProperty() default property, an invalid QmlMetaProperty will be created. */ QmlMetaProperty::QmlMetaProperty(QObject *obj) +: d(new QmlMetaPropertyPrivate) { + d->q = this; d->initDefault(obj); } @@ -146,6 +149,7 @@ QmlMetaProperty::QmlMetaProperty(QObject *obj) QmlMetaProperty::QmlMetaProperty(QObject *obj, QmlContext *ctxt) : d(new QmlMetaPropertyPrivate) { + d->q = this; d->context = ctxt; d->initDefault(obj); } @@ -175,6 +179,7 @@ void QmlMetaPropertyPrivate::initDefault(QObject *obj) QmlMetaProperty::QmlMetaProperty(QObject *obj, int idx, QmlContext *ctxt) : d(new QmlMetaPropertyPrivate) { + d->q = this; d->context = ctxt; d->object = obj; d->type = Property; @@ -191,6 +196,7 @@ QmlMetaProperty::QmlMetaProperty(QObject *obj, int idx, QmlContext *ctxt) QmlMetaProperty::QmlMetaProperty(QObject *obj, const QString &name) : d(new QmlMetaPropertyPrivate) { + d->q = this; d->initProperty(obj, name); } @@ -201,6 +207,7 @@ QmlMetaProperty::QmlMetaProperty(QObject *obj, const QString &name) QmlMetaProperty::QmlMetaProperty(QObject *obj, const QString &name, QmlContext *ctxt) : d(new QmlMetaPropertyPrivate) { + d->q = this; d->context = ctxt; d->initProperty(obj, name); } @@ -276,6 +283,7 @@ void QmlMetaPropertyPrivate::initProperty(QObject *obj, const QString &name) QmlMetaProperty::QmlMetaProperty(const QmlMetaProperty &other) : d(new QmlMetaPropertyPrivate(*other.d)) { + d->q = this; } /*! @@ -560,9 +568,10 @@ QmlMetaProperty::setBinding(QmlAbstractBinding *newBinding) const if (!isProperty() || (type() & Attached) || !d->object) return 0; - QmlDeclarativeData *data = QmlDeclarativeData::get(d->object, true); + QmlDeclarativeData *data = + QmlDeclarativeData::get(d->object, 0 != newBinding); - if (data->hasBindingBit(d->coreIdx)) { + if (data && data->hasBindingBit(d->coreIdx)) { QmlAbstractBinding *binding = data->bindings; while (binding) { // ### This wont work for value types @@ -584,7 +593,6 @@ QmlMetaProperty::setBinding(QmlAbstractBinding *newBinding) const return 0; } - /*! Returns the expression associated with this signal property, or 0 if no signal expression exists. @@ -743,6 +751,10 @@ void QmlMetaPropertyPrivate::writeValueProperty(const QVariant &value, int writeBackIdx = -1; bool deleteWriteBack = false; + // Remove any existing bindings on this property + if (source != QmlMetaProperty::Binding) + delete q->setBinding(0); + if (type & QmlMetaProperty::ValueTypeProperty) { QmlEnginePrivate *ep = context?static_cast<QmlEnginePrivate *>(QObjectPrivate::get(context->engine())):0; diff --git a/src/declarative/qml/qmlmetaproperty_p.h b/src/declarative/qml/qmlmetaproperty_p.h index f2d0039..1ccf913 100644 --- a/src/declarative/qml/qmlmetaproperty_p.h +++ b/src/declarative/qml/qmlmetaproperty_p.h @@ -85,16 +85,18 @@ class QmlMetaPropertyPrivate { public: QmlMetaPropertyPrivate() - : context(0), coreIdx(-1), valueTypeIdx(-1), valueTypeId(0), + : q(0), context(0), coreIdx(-1), valueTypeIdx(-1), valueTypeId(0), type(QmlMetaProperty::Invalid), attachedFunc(-1), object(0), propType(-1), category(QmlMetaProperty::Unknown) {} QmlMetaPropertyPrivate(const QmlMetaPropertyPrivate &other) - : name(other.name), signal(other.signal), context(other.context), + : q(0), name(other.name), signal(other.signal), context(other.context), coreIdx(other.coreIdx), valueTypeIdx(other.valueTypeIdx), valueTypeId(other.valueTypeId), type(other.type), attachedFunc(other.attachedFunc), object(other.object), propType(other.propType), category(other.category) {} + QmlMetaProperty *q; + QString name; QMetaMethod signal; QmlContext *context; 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" |