aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmllanguage
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-03-12 13:00:46 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-13 13:58:40 +0100
commit110c38a8a6fa30ad8e114d26df88fc3c23ec42de (patch)
treea1a11f0363cea0ad9220dbbe30989566c055bf0d /tests/auto/qml/qqmllanguage
parent1ddd4f8f0641948aabfd1031a080720e8dc61984 (diff)
Fix property caches out of sync with grouped properties that have a VME meta object
Because QQmlObjectCreator::populateInstance would take the property cache to install from the outside and also pass it as the cache to use for the VME meta object to install, it could happen that the wrong cache was installed - the one supplied by engine->cache(propType) instead of the cache created together with the VME meta-object at type compilation time. This patch ensures that they're always in sync and correct by removing the responsibility of the caller to supply the cache to use and install. Instead the function will always use the cache calculated at type compile time (and also use that when installing the VME meta object). Installation of the property cache on the declarative data of the instance is now done only at createInstance() time, which fortunately also simplifies the code. Change-Id: Ia722cd57bc48007aaf725f1f59daa2f21569e324 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests/auto/qml/qqmllanguage')
-rw-r--r--tests/auto/qml/qqmllanguage/data/propertyCacheInSync.qml9
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp22
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/propertyCacheInSync.qml b/tests/auto/qml/qqmllanguage/data/propertyCacheInSync.qml
new file mode 100644
index 0000000000..35fa4be6eb
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/propertyCacheInSync.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.0
+Item {
+ anchors {
+ margins: 50
+ Behavior on margins {
+ NumberAnimation { duration: 10 }
+ }
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index c7a26c72db..fa0c393d66 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -56,6 +56,7 @@
#include <private/qqmlmetatype_p.h>
#include <private/qqmlglobal_p.h>
#include <private/qqmlscriptstring_p.h>
+#include <private/qqmlvmemetaobject_p.h>
#include "testtypes.h"
#include "testhttpserver.h"
@@ -219,6 +220,7 @@ private slots:
void customParserEvaluateEnum();
void preservePropertyCacheOnGroupObjects();
+ void propertyCacheInSync();
private:
QQmlEngine engine;
@@ -3602,6 +3604,26 @@ void tst_qqmllanguage::preservePropertyCacheOnGroupObjects()
QCOMPARE(pd->propType, qMetaTypeId<int>());
}
+void tst_qqmllanguage::propertyCacheInSync()
+{
+ QQmlComponent component(&engine, testFile("propertyCacheInSync.qml"));
+ VERIFY_ERRORS(0);
+ QScopedPointer<QObject> o(component.create());
+ QVERIFY(!o.isNull());
+ QObject *anchors = qvariant_cast<QObject*>(o->property("anchors"));
+ QVERIFY(anchors);
+ QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(anchors);
+ QVERIFY(vmemo);
+ QQmlPropertyCache *vmemoCache = vmemo->propertyCache();
+ QVERIFY(vmemoCache);
+ QQmlData *ddata = QQmlData::get(anchors);
+ QVERIFY(ddata);
+ QVERIFY(ddata->propertyCache);
+ // Those always have to be in sync and correct.
+ QVERIFY(ddata->propertyCache == vmemoCache);
+ QCOMPARE(anchors->property("margins").toInt(), 50);
+}
+
QTEST_MAIN(tst_qqmllanguage)
#include "tst_qqmllanguage.moc"