summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp6
-rw-r--r--tests/auto/declarative/qdeclarativecomponent/data/createObjectWithScript.qml2
-rw-r--r--tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp2
3 files changed, 8 insertions, 2 deletions
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index b634a7a..06bf3fd 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -715,7 +715,11 @@ QScriptValue QDeclarativeComponentPrivate::createObject(QObject *publicParent, c
QScriptValueIterator it(valuemap);
while (it.hasNext()) {
it.next();
- newObject.setProperty(it.name(), it.value(), QScriptValue::KeepExistingFlags);
+ if (it.value().isFunction()) { // To allow property binding from javascript to work
+ newObject.setProperty(it.name(), it.value());
+ } else {
+ QDeclarativeProperty::write(ret,it.name(),it.value().toVariant());
+ }
}
}
diff --git a/tests/auto/declarative/qdeclarativecomponent/data/createObjectWithScript.qml b/tests/auto/declarative/qdeclarativecomponent/data/createObjectWithScript.qml
index 6f9ddc1..2ce76ed 100644
--- a/tests/auto/declarative/qdeclarativecomponent/data/createObjectWithScript.qml
+++ b/tests/auto/declarative/qdeclarativecomponent/data/createObjectWithScript.qml
@@ -29,7 +29,7 @@ Item{
}
Component.onCompleted: {
- root.declarativerectangle = a.createObject(root, {"x":17,"y":17, "color":"white"});
+ root.declarativerectangle = a.createObject(root, {"x":17,"y":17, "color":"white", "border.width":3});
root.declarativeitem = b.createObject(root, {"x":17,"y":17,"testBool":true,"testInt":17,"testObject":root});
root.bindingTestObject = c.createObject(root, {'testValue': (function(){return width * 3}) }) // use root.width
diff --git a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp
index 62c6bb5..7b7b392 100644
--- a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp
+++ b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp
@@ -45,6 +45,7 @@
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativecomponent.h>
#include <QtDeclarative/qdeclarativeitem.h>
+#include <QtDeclarative/qdeclarativeproperty.h>
#include <qcolor.h>
#ifdef Q_OS_SYMBIAN
@@ -135,6 +136,7 @@ void tst_qdeclarativecomponent::qmlCreateObjectWithProperties()
QCOMPARE(testObject1->property("x").value<int>(), 17);
QCOMPARE(testObject1->property("y").value<int>(), 17);
QCOMPARE(testObject1->property("color").value<QColor>(), QColor(255,255,255));
+ QCOMPARE(QDeclarativeProperty::read(testObject1,"border.width").toInt(), 3);
delete testObject1;
QObject *testObject2 = object->property("declarativeitem").value<QObject*>();