aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp11
-rw-r--r--src/qml/qml/v8/qv8qobjectwrapper.cpp2
-rw-r--r--tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp29
3 files changed, 39 insertions, 3 deletions
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
index b1ffc9a2d5..dee9f26c80 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -1328,8 +1328,14 @@ QQmlPropertyData qQmlPropertyCacheCreate(const QMetaObject *metaObject, const QS
rv.load(p);
return rv;
} else {
- while (cmo && cmo->propertyOffset() >= idx)
+ bool changed = false;
+ while (cmo && cmo->propertyOffset() >= idx) {
cmo = cmo->superClass();
+ changed = true;
+ }
+ /* If the "cmo" variable didn't change, set it to 0 to
+ * avoid running into an infinite loop */
+ if (!changed) cmo = 0;
}
} else {
cmo = 0;
@@ -1395,7 +1401,8 @@ qQmlPropertyCacheProperty(QQmlEngine *engine, QObject *obj, const T &name,
if (cache) {
rv = cache->property(name, obj, context);
- } else {
+ }
+ if (!rv) {
local = qQmlPropertyCacheCreate(obj->metaObject(), qQmlPropertyCacheToString(name));
if (local.isValid())
rv = &local;
diff --git a/src/qml/qml/v8/qv8qobjectwrapper.cpp b/src/qml/qml/v8/qv8qobjectwrapper.cpp
index 0336457027..53f70ad132 100644
--- a/src/qml/qml/v8/qv8qobjectwrapper.cpp
+++ b/src/qml/qml/v8/qv8qobjectwrapper.cpp
@@ -524,7 +524,7 @@ v8::Handle<v8::Value> QV8QObjectWrapper::GetProperty(QV8Engine *engine, QObject
QQmlData *ddata = QQmlData::get(object, false);
if (ddata && ddata->propertyCache)
result = ddata->propertyCache->property(property, object, context);
- else
+ if (!result)
result = QQmlPropertyCache::property(engine->engine(), object, property, context, local);
}
diff --git a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp
index 327716f1b5..2b772ba9c4 100644
--- a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp
+++ b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp
@@ -66,6 +66,7 @@ private slots:
void crashBug();
void QTBUG_17868();
void metaObjectAccessibility();
+ void QTBUG_31226();
};
void tst_QQmlPropertyMap::insert()
@@ -312,6 +313,34 @@ void tst_QQmlPropertyMap::metaObjectAccessibility()
QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString()));
}
+void tst_QQmlPropertyMap::QTBUG_31226()
+{
+ /* Instantiate a property map from QML, and verify that property changes
+ * made from C++ are visible from QML */
+ QQmlEngine engine;
+ QQmlContext context(&engine);
+ qmlRegisterType<QQmlPropertyMap>("QTBUG_31226", 1, 0, "PropertyMap");
+ QQmlComponent c(&engine);
+ c.setData("import QtQuick 2.0\nimport QTBUG_31226 1.0\n"
+ "Item {\n"
+ " property string myProp\n"
+ " PropertyMap { id: qmlPropertyMap; objectName: \"qmlPropertyMap\" }\n"
+ " Timer { interval: 5; running: true; onTriggered: { myProp = qmlPropertyMap.greeting; } }\n"
+ "}",
+ QUrl());
+ QObject *obj = c.create(&context);
+ QVERIFY(obj);
+
+ QQmlPropertyMap *qmlPropertyMap = obj->findChild<QQmlPropertyMap*>(QString("qmlPropertyMap"));
+ QVERIFY(qmlPropertyMap);
+
+ qmlPropertyMap->insert("greeting", QString("Hello world!"));
+ QTRY_COMPARE(obj->property("myProp").toString(), QString("Hello world!"));
+
+ delete obj;
+
+}
+
QTEST_MAIN(tst_QQmlPropertyMap)
#include "tst_qqmlpropertymap.moc"