aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2011-07-25 13:06:28 +1000
committerQt by Nokia <qt-info@nokia.com>2011-07-25 06:08:56 +0200
commit9cb3889b33a4a92db40a3a72c3ee4fa25770d539 (patch)
tree01b25e5a091a4a7874e6e300a42fd3cd40ee9f8f
parente826e578eaef3f05498124eb2057f41410696480 (diff)
Correctly load flags for binding properties
Change-Id: I80e79ff7de8d879f700f9f4fe96d796de0f17aff Reviewed-on: http://codereview.qt.nokia.com/2055 Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp14
-rw-r--r--src/declarative/qml/qdeclarativeproperty.cpp12
-rw-r--r--src/declarative/qml/qdeclarativeproperty_p.h6
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/ElementAssignType.qml5
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/elementAssign.qml10
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp15
6 files changed, 49 insertions, 13 deletions
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index d0fd3ae4f4..581a538b4b 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 088379e8d2..9b7431a58c 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 efebf0ca48..ea3fb56f8f 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 0000000000..4127ca4375
--- /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 0000000000..61854df71c
--- /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 22c2096ea4..1f6427b06e 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()