From: Aaron Kennedy Date: Mon, 25 Jul 2011 03:06:28 +0000 (+1000) Subject: Correctly load flags for binding properties X-Git-Tag: qt-v5.0.0-alpha1~2100 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9cb3889b33a4a92db40a3a72c3ee4fa25770d539;p=profile%2Fivi%2Fqtdeclarative.git Correctly load flags for binding properties Change-Id: I80e79ff7de8d879f700f9f4fe96d796de0f17aff Reviewed-on: http://codereview.qt.nokia.com/2055 Reviewed-by: Aaron Kennedy --- diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index d0fd3ae..581a538 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -2910,18 +2910,20 @@ int QDeclarativeCompiler::genContextCache() int QDeclarativeCompiler::genValueTypeData(QDeclarativeParser::Property *valueTypeProp, QDeclarativeParser::Property *prop) { - QByteArray data = - QDeclarativePropertyPrivate::saveValueType(prop->parent->metaObject(), prop->index, - enginePrivate->valueTypes[prop->type]->metaObject(), - valueTypeProp->index); -// valueTypeProp->index, valueTypeProp->type); + typedef QDeclarativePropertyPrivate QDPP; + QByteArray data = QDPP::saveValueType(prop->parent->metaObject(), prop->index, + enginePrivate->valueTypes[prop->type]->metaObject(), + valueTypeProp->index, engine); return output->indexForByteArray(data); } int QDeclarativeCompiler::genPropertyData(QDeclarativeParser::Property *prop) { - return output->indexForByteArray(QDeclarativePropertyPrivate::saveProperty(prop->parent->metaObject(), prop->index)); + typedef QDeclarativePropertyPrivate QDPP; + QByteArray data = QDPP::saveProperty(prop->parent->metaObject(), prop->index, engine); + + return output->indexForByteArray(data); } bool QDeclarativeCompiler::completeComponentBuild() diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index 088379e..9b7431a 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -1095,8 +1095,8 @@ bool QDeclarativePropertyPrivate::writeValueProperty(const QVariant &value, Writ } bool QDeclarativePropertyPrivate::write(QObject *object, const QDeclarativePropertyCache::Data &property, - const QVariant &value, QDeclarativeContextData *context, - WriteFlags flags) + const QVariant &value, QDeclarativeContextData *context, + WriteFlags flags) { int coreIdx = property.coreIndex; int status = -1; //for dbus @@ -1549,7 +1549,8 @@ struct ValueTypeSerializedData : public SerializedData { }; QByteArray QDeclarativePropertyPrivate::saveValueType(const QMetaObject *metaObject, int index, - const QMetaObject *subObject, int subIndex) + const QMetaObject *subObject, int subIndex, + QDeclarativeEngine *) { QMetaProperty prop = metaObject->property(index); QMetaProperty subProp = subObject->property(subIndex); @@ -1567,12 +1568,13 @@ QByteArray QDeclarativePropertyPrivate::saveValueType(const QMetaObject *metaObj return rv; } -QByteArray QDeclarativePropertyPrivate::saveProperty(const QMetaObject *metaObject, int index) +QByteArray QDeclarativePropertyPrivate::saveProperty(const QMetaObject *metaObject, int index, + QDeclarativeEngine *engine) { SerializedData sd; memset(&sd, 0, sizeof(sd)); sd.isValueType = false; - sd.core.load(metaObject->property(index)); + sd.core.load(metaObject->property(index), engine); QByteArray rv((const char *)&sd, sizeof(sd)); return rv; diff --git a/src/declarative/qml/qdeclarativeproperty_p.h b/src/declarative/qml/qdeclarativeproperty_p.h index efebf0c..ea3fb56 100644 --- a/src/declarative/qml/qdeclarativeproperty_p.h +++ b/src/declarative/qml/qdeclarativeproperty_p.h @@ -111,8 +111,10 @@ public: static QDeclarativeAbstractBinding *binding(QObject *, int coreIndex, int valueTypeIndex /* -1 */); static QByteArray saveValueType(const QMetaObject *, int, - const QMetaObject *, int); - static QByteArray saveProperty(const QMetaObject *, int); + const QMetaObject *, int, + QDeclarativeEngine *); + static QByteArray saveProperty(const QMetaObject *, int, + QDeclarativeEngine *); static QDeclarativeProperty restore(const QByteArray &, QObject *, QDeclarativeContextData *); static QDeclarativeProperty restore(const QDeclarativePropertyCache::Data &, diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/ElementAssignType.qml b/tests/auto/declarative/qdeclarativeecmascript/data/ElementAssignType.qml new file mode 100644 index 0000000..4127ca4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/ElementAssignType.qml @@ -0,0 +1,5 @@ +import QtQuick 1.0 + +QtObject { + property int value +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/elementAssign.qml b/tests/auto/declarative/qdeclarativeecmascript/data/elementAssign.qml new file mode 100644 index 0000000..61854df --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/elementAssign.qml @@ -0,0 +1,10 @@ +import QtQuick 1.0 + +QtObject { + id: root + + property bool test: bound.value == 1923 + + property ElementAssignType element: ElementAssignType { value: 1923 } + property ElementAssignType bound: root.element +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 22c2096..1f6427b 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -148,6 +148,7 @@ private slots: void importScripts(); void scarceResources(); void propertyChangeSlots(); + void elementAssign(); void bug1(); void bug2(); @@ -189,6 +190,7 @@ private slots: void revisionErrors(); void revision(); + private: QDeclarativeEngine engine; }; @@ -2909,6 +2911,19 @@ void tst_qdeclarativeecmascript::propertyChangeSlots() delete object; } +// Ensure that QObject type conversion works on binding assignment +void tst_qdeclarativeecmascript::elementAssign() +{ + QDeclarativeComponent component(&engine, TEST_FILE("elementAssign.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; +} + // Test that assigning a null object works // Regressed with: df1788b4dbbb2826ae63f26bdf166342595343f4 void tst_qdeclarativeecmascript::nullObjectBinding()