aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-02-20 12:51:02 +0100
committerUlf Hermann <ulf.hermann@qt.io>2019-02-21 15:47:10 +0000
commit30db7d94e002b5c5b29820050a2220ef06afa54c (patch)
treed132dae16610cfdd9ef71118ee377dadca1d37fc
parentba2ff45daae4e6167f7719ab1466023093031a75 (diff)
QML: Pass type minor version when creating property data
Depending on the type minor version recursive properties should be available or not. Check for that when resolving grouped properties. Fixes: QTBUG-33179 Change-Id: Id8f62befdc4a29d879710499e19d3d289bd18775 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--src/qml/compiler/qqmlpropertycachecreator.cpp2
-rw-r--r--src/qml/compiler/qqmlpropertyvalidator.cpp8
-rw-r--r--src/qml/compiler/qv4compileddata.cpp2
-rw-r--r--src/qml/jsapi/qjsengine_p.h12
-rw-r--r--src/qml/qml/qqmlengine_p.h2
-rw-r--r--src/qml/qml/qqmlmetatype.cpp14
-rw-r--r--src/qml/qml/qqmlmetatype_p.h2
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp9
-rw-r--r--src/qml/qml/qqmlpropertycache_p.h4
-rw-r--r--tests/auto/qml/qqmlmetatype/data/revisionedGroupedPropertiesInvalid.qml6
-rw-r--r--tests/auto/qml/qqmlmetatype/data/revisionedGroupedPropertiesValid.qml6
-rw-r--r--tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp57
12 files changed, 97 insertions, 27 deletions
diff --git a/src/qml/compiler/qqmlpropertycachecreator.cpp b/src/qml/compiler/qqmlpropertycachecreator.cpp
index fd22cd58f1..fb54da5b73 100644
--- a/src/qml/compiler/qqmlpropertycachecreator.cpp
+++ b/src/qml/compiler/qqmlpropertycachecreator.cpp
@@ -74,7 +74,7 @@ QQmlRefPointer<QQmlPropertyCache> QQmlBindingInstantiationContext::instantiating
if (instantiatingProperty->isQObject()) {
return enginePrivate->rawPropertyCacheForType(instantiatingProperty->propType(), instantiatingProperty->typeMinorVersion());
} else if (const QMetaObject *vtmo = QQmlValueTypeFactory::metaObjectForMetaType(instantiatingProperty->propType())) {
- return enginePrivate->cache(vtmo);
+ return enginePrivate->cache(vtmo, instantiatingProperty->typeMinorVersion());
}
}
return QQmlRefPointer<QQmlPropertyCache>();
diff --git a/src/qml/compiler/qqmlpropertyvalidator.cpp b/src/qml/compiler/qqmlpropertyvalidator.cpp
index 414fea77b1..5e821518a4 100644
--- a/src/qml/compiler/qqmlpropertyvalidator.cpp
+++ b/src/qml/compiler/qqmlpropertyvalidator.cpp
@@ -160,10 +160,12 @@ QVector<QQmlCompileError> QQmlPropertyValidator::validateObject(int objectIndex,
QQmlPropertyData *pd = nullptr;
if (!name.isEmpty()) {
if (binding->flags & QV4::CompiledData::Binding::IsSignalHandlerExpression
- || binding->flags & QV4::CompiledData::Binding::IsSignalHandlerObject)
+ || binding->flags & QV4::CompiledData::Binding::IsSignalHandlerObject) {
pd = propertyResolver.signal(name, &notInRevision);
- else
- pd = propertyResolver.property(name, &notInRevision, isGroupProperty ? QmlIR::PropertyResolver::IgnoreRevision : QmlIR::PropertyResolver::CheckRevision);
+ } else {
+ pd = propertyResolver.property(name, &notInRevision,
+ QmlIR::PropertyResolver::CheckRevision);
+ }
if (notInRevision) {
QString typeName = stringAt(obj->inheritedTypeNameIndex);
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp
index d205d8be8b..65690ec1f6 100644
--- a/src/qml/compiler/qv4compileddata.cpp
+++ b/src/qml/compiler/qv4compileddata.cpp
@@ -851,7 +851,7 @@ QQmlRefPointer<QQmlPropertyCache> ResolvedTypeReference::createPropertyCache(QQm
if (typePropertyCache) {
return typePropertyCache;
} else if (type.isValid()) {
- typePropertyCache = QQmlEnginePrivate::get(engine)->cache(type.metaObject());
+ typePropertyCache = QQmlEnginePrivate::get(engine)->cache(type.metaObject(), minorVersion);
return typePropertyCache;
} else {
return compilationUnit->rootPropertyCache();
diff --git a/src/qml/jsapi/qjsengine_p.h b/src/qml/jsapi/qjsengine_p.h
index 360c9df075..a77d710cff 100644
--- a/src/qml/jsapi/qjsengine_p.h
+++ b/src/qml/jsapi/qjsengine_p.h
@@ -109,8 +109,8 @@ public:
// These methods may be called from the QML loader thread
- inline QQmlPropertyCache *cache(QObject *obj);
- inline QQmlPropertyCache *cache(const QMetaObject *);
+ inline QQmlPropertyCache *cache(QObject *obj, int minorVersion = -1);
+ inline QQmlPropertyCache *cache(const QMetaObject *, int minorVersion = -1);
};
QJSEnginePrivate::Locker::Locker(const QJSEngine *e)
@@ -160,14 +160,14 @@ and deleted before the loader thread has a chance to use or reference it. This
can't currently happen as the cache holds a reference to the
QQmlPropertyCache until the QQmlEngine is destroyed.
*/
-QQmlPropertyCache *QJSEnginePrivate::cache(QObject *obj)
+QQmlPropertyCache *QJSEnginePrivate::cache(QObject *obj, int minorVersion)
{
if (!obj || QObjectPrivate::get(obj)->metaObject || QObjectPrivate::get(obj)->wasDeleted)
return nullptr;
Locker locker(this);
const QMetaObject *mo = obj->metaObject();
- return QQmlMetaType::propertyCache(mo);
+ return QQmlMetaType::propertyCache(mo, minorVersion);
}
/*!
@@ -179,12 +179,12 @@ exist for the lifetime of the QQmlEngine.
The returned cache is not referenced, so if it is to be stored, call addref().
*/
-QQmlPropertyCache *QJSEnginePrivate::cache(const QMetaObject *metaObject)
+QQmlPropertyCache *QJSEnginePrivate::cache(const QMetaObject *metaObject, int minorVersion)
{
Q_ASSERT(metaObject);
Locker locker(this);
- return QQmlMetaType::propertyCache(metaObject);
+ return QQmlMetaType::propertyCache(metaObject, minorVersion);
}
diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h
index 3caa6ec138..8a9581fb35 100644
--- a/src/qml/qml/qqmlengine_p.h
+++ b/src/qml/qml/qqmlengine_p.h
@@ -377,7 +377,7 @@ QQmlPropertyCache *QQmlEnginePrivate::cache(const QQmlType &type, int minorVersi
Q_ASSERT(type.isValid());
if (minorVersion == -1 || !type.containsRevisionedAttributes())
- return cache(type.metaObject());
+ return cache(type.metaObject(), minorVersion);
Locker locker(this);
return QQmlMetaType::propertyCache(type, minorVersion);
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index 708859be00..8db0bc92b8 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -118,7 +118,7 @@ struct QQmlMetaTypeData
QHash<int, int> qmlLists;
QHash<const QMetaObject *, QQmlPropertyCache *> propertyCaches;
- QQmlPropertyCache *propertyCache(const QMetaObject *metaObject);
+ QQmlPropertyCache *propertyCache(const QMetaObject *metaObject, int minorVersion);
QQmlPropertyCache *propertyCache(const QQmlType &type, int minorVersion);
void startRecordingTypeRegFailures(QStringList *storage)
@@ -2436,7 +2436,7 @@ QQmlType QQmlMetaType::qmlType(const QUrl &unNormalizedUrl, bool includeNonFileI
return QQmlType();
}
-QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QMetaObject *metaObject)
+QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QMetaObject *metaObject, int minorVersion)
{
if (QQmlPropertyCache *rv = propertyCaches.value(metaObject))
return rv;
@@ -2446,17 +2446,17 @@ QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QMetaObject *metaObject
propertyCaches.insert(metaObject, rv);
return rv;
}
- QQmlPropertyCache *super = propertyCache(metaObject->superClass());
- QQmlPropertyCache *rv = super->copyAndAppend(metaObject);
+ QQmlPropertyCache *super = propertyCache(metaObject->superClass(), minorVersion);
+ QQmlPropertyCache *rv = super->copyAndAppend(metaObject, minorVersion);
propertyCaches.insert(metaObject, rv);
return rv;
}
-QQmlPropertyCache *QQmlMetaType::propertyCache(const QMetaObject *metaObject)
+QQmlPropertyCache *QQmlMetaType::propertyCache(const QMetaObject *metaObject, int minorVersion)
{
QMutexLocker lock(metaTypeDataLock());
QQmlMetaTypeData *data = metaTypeData();
- return data->propertyCache(metaObject);
+ return data->propertyCache(metaObject, minorVersion);
}
QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QQmlType &type, int minorVersion)
@@ -2489,7 +2489,7 @@ QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QQmlType &type, int min
return pc;
}
- QQmlPropertyCache *raw = propertyCache(type.metaObject());
+ QQmlPropertyCache *raw = propertyCache(type.metaObject(), minorVersion);
bool hasCopied = false;
diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h
index b3ca6acd64..8256212207 100644
--- a/src/qml/qml/qqmlmetatype_p.h
+++ b/src/qml/qml/qqmlmetatype_p.h
@@ -103,7 +103,7 @@ public:
static QQmlType qmlType(int typeId, TypeIdCategory category = TypeIdCategory::MetaType);
static QQmlType qmlType(const QUrl &unNormalizedUrl, bool includeNonFileImports = false);
- static QQmlPropertyCache *propertyCache(const QMetaObject *metaObject);
+ static QQmlPropertyCache *propertyCache(const QMetaObject *metaObject, int minorVersion = -1);
static QQmlPropertyCache *propertyCache(const QQmlType &type, int minorVersion);
static void freeUnusedTypesAndCaches();
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
index 629717dd9f..20d5c76029 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -464,7 +464,7 @@ QQmlPropertyCache::copyAndAppend(const QMetaObject *metaObject,
QQmlPropertyCache *
QQmlPropertyCache::copyAndAppend(const QMetaObject *metaObject,
- int revision,
+ int typeMinorVersion,
QQmlPropertyData::Flags propertyFlags,
QQmlPropertyData::Flags methodFlags,
QQmlPropertyData::Flags signalFlags)
@@ -478,19 +478,17 @@ QQmlPropertyCache::copyAndAppend(const QMetaObject *metaObject,
QMetaObjectPrivate::get(metaObject)->signalCount +
QMetaObjectPrivate::get(metaObject)->propertyCount);
- rv->append(metaObject, revision, propertyFlags, methodFlags, signalFlags);
+ rv->append(metaObject, typeMinorVersion, propertyFlags, methodFlags, signalFlags);
return rv;
}
void QQmlPropertyCache::append(const QMetaObject *metaObject,
- int revision,
+ int typeMinorVersion,
QQmlPropertyData::Flags propertyFlags,
QQmlPropertyData::Flags methodFlags,
QQmlPropertyData::Flags signalFlags)
{
- Q_UNUSED(revision);
-
_metaObject = metaObject;
bool dynamicMetaObject = isDynamicMetaObject(metaObject);
@@ -640,6 +638,7 @@ void QQmlPropertyCache::append(const QMetaObject *metaObject,
data->setFlags(propertyFlags);
data->lazyLoad(p);
+ data->setTypeMinorVersion(typeMinorVersion);
data->_flags.isDirect = !dynamicMetaObject;
diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h
index a7cbd506f9..c3c818eb77 100644
--- a/src/qml/qml/qqmlpropertycache_p.h
+++ b/src/qml/qml/qqmlpropertycache_p.h
@@ -408,7 +408,7 @@ public:
QQmlPropertyRawData::Flags propertyFlags = QQmlPropertyData::Flags(),
QQmlPropertyRawData::Flags methodFlags = QQmlPropertyData::Flags(),
QQmlPropertyRawData::Flags signalFlags = QQmlPropertyData::Flags());
- QQmlPropertyCache *copyAndAppend(const QMetaObject *, int revision,
+ QQmlPropertyCache *copyAndAppend(const QMetaObject *, int typeMinorVersion,
QQmlPropertyRawData::Flags propertyFlags = QQmlPropertyData::Flags(),
QQmlPropertyRawData::Flags methodFlags = QQmlPropertyData::Flags(),
QQmlPropertyRawData::Flags signalFlags = QQmlPropertyData::Flags());
@@ -499,7 +499,7 @@ private:
inline QQmlPropertyCache *copy(int reserve);
- void append(const QMetaObject *, int revision,
+ void append(const QMetaObject *, int typeMinorVersion,
QQmlPropertyRawData::Flags propertyFlags = QQmlPropertyRawData::Flags(),
QQmlPropertyRawData::Flags methodFlags = QQmlPropertyData::Flags(),
QQmlPropertyRawData::Flags signalFlags = QQmlPropertyData::Flags());
diff --git a/tests/auto/qml/qqmlmetatype/data/revisionedGroupedPropertiesInvalid.qml b/tests/auto/qml/qqmlmetatype/data/revisionedGroupedPropertiesInvalid.qml
new file mode 100644
index 0000000000..df6d801cde
--- /dev/null
+++ b/tests/auto/qml/qqmlmetatype/data/revisionedGroupedPropertiesInvalid.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+import GroupedTest 1.0
+
+MyItem {
+ grouped.prop: 5
+}
diff --git a/tests/auto/qml/qqmlmetatype/data/revisionedGroupedPropertiesValid.qml b/tests/auto/qml/qqmlmetatype/data/revisionedGroupedPropertiesValid.qml
new file mode 100644
index 0000000000..b7ea017acf
--- /dev/null
+++ b/tests/auto/qml/qqmlmetatype/data/revisionedGroupedPropertiesValid.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+import GroupedTest 1.1
+
+MyItem {
+ grouped.prop: 5
+}
diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
index 7139a1c952..ce72f40dcc 100644
--- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
+++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
@@ -66,6 +66,7 @@ private slots:
void normalizeUrls();
void unregisterAttachedProperties();
+ void revisionedGroupedProperties();
};
class TestType : public QObject
@@ -572,6 +573,62 @@ void tst_qqmlmetatype::unregisterAttachedProperties()
}
}
+class Grouped : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int prop READ prop WRITE setProp NOTIFY propChanged REVISION 1)
+public:
+ int prop() const { return m_prop; }
+ void setProp(int prop)
+ {
+ if (prop != m_prop) {
+ m_prop = prop;
+ emit propChanged(prop);
+ }
+ }
+
+signals:
+ Q_REVISION(1) void propChanged(int prop);
+
+private:
+ int m_prop = 0;
+};
+
+class MyItem : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(Grouped *grouped READ grouped CONSTANT)
+public:
+ MyItem() : m_grouped(new Grouped) {}
+ Grouped *grouped() const { return m_grouped.data(); }
+
+private:
+ QScopedPointer<Grouped> m_grouped;
+};
+
+void tst_qqmlmetatype::revisionedGroupedProperties()
+{
+ qmlClearTypeRegistrations();
+ qmlRegisterType<MyItem>("GroupedTest", 1, 0, "MyItem");
+ qmlRegisterType<MyItem, 1>("GroupedTest", 1, 1, "MyItem");
+ qmlRegisterUncreatableType<Grouped>("GroupedTest", 1, 0, "Grouped", "Grouped");
+ qmlRegisterUncreatableType<Grouped, 1>("GroupedTest", 1, 1, "Grouped", "Grouped");
+
+ {
+ QQmlEngine engine;
+ QQmlComponent valid(&engine, testFileUrl("revisionedGroupedPropertiesValid.qml"));
+ QVERIFY(valid.isReady());
+ QScopedPointer<QObject> obj(valid.create());
+ QVERIFY(!obj.isNull());
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent invalid(&engine, testFileUrl("revisionedGroupedPropertiesInvalid.qml"));
+ QVERIFY(invalid.isError());
+ }
+}
+
QTEST_MAIN(tst_qqmlmetatype)
#include "tst_qqmlmetatype.moc"