aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlmetatype.cpp
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-04-19 01:00:04 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-04-19 01:00:04 +0200
commit53bd6b8111eb0d7f23b3b0ca95bef4735f7a952c (patch)
treef4b1407fa828e4d6ac608dbef97b4b9f3203a7cc /src/qml/qml/qqmlmetatype.cpp
parent2bdbf216fe7b6cf9d404b80ac405bd3969f5c07f (diff)
parentc018df5b4075ae962966d4df7653d476dab02840 (diff)
Merge remote-tracking branch 'origin/5.12' into 5.13
Diffstat (limited to 'src/qml/qml/qqmlmetatype.cpp')
-rw-r--r--src/qml/qml/qqmlmetatype.cpp35
1 files changed, 12 insertions, 23 deletions
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index a8ec5d18f8..b21c3ec40d 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -224,7 +224,6 @@ public:
QQmlCustomParser *customParser;
QQmlAttachedPropertiesFunc attachedPropertiesFunc;
const QMetaObject *attachedPropertiesType;
- int attachedPropertiesId;
int propertyValueSourceCast;
int propertyValueInterceptorCast;
bool registerEnumClassesUnscoped;
@@ -269,8 +268,6 @@ public:
mutable QStringHash<int> scopedEnumIndex; // maps from enum name to index in scopedEnums
mutable QList<QStringHash<int>*> scopedEnums;
- static QHash<const QMetaObject *, int> attachedPropertyIds;
-
struct PropertyCacheByMinorVersion
{
PropertyCacheByMinorVersion() : cache(nullptr), minorVersion(-1) {}
@@ -363,8 +360,6 @@ QJSValue QQmlType::SingletonInstanceInfo::scriptApi(QQmlEngine *e) const
return scriptApis.value(e);
}
-QHash<const QMetaObject *, int> QQmlTypePrivate::attachedPropertyIds;
-
QQmlTypePrivate::QQmlTypePrivate(QQmlType::RegistrationType type)
: refCount(1), regType(type), iid(nullptr), typeId(0), listId(0), revision(0),
containsRevisionedAttributes(false), baseMetaObject(nullptr),
@@ -498,14 +493,6 @@ QQmlType::QQmlType(QQmlMetaTypeData *data, const QString &elementName, const QQm
d->baseMetaObject = type.metaObject;
d->extraData.cd->attachedPropertiesFunc = type.attachedPropertiesFunction;
d->extraData.cd->attachedPropertiesType = type.attachedPropertiesMetaObject;
- if (d->extraData.cd->attachedPropertiesType) {
- auto iter = QQmlTypePrivate::attachedPropertyIds.find(d->baseMetaObject);
- if (iter == QQmlTypePrivate::attachedPropertyIds.end())
- iter = QQmlTypePrivate::attachedPropertyIds.insert(d->baseMetaObject, d->index);
- d->extraData.cd->attachedPropertiesId = *iter;
- } else {
- d->extraData.cd->attachedPropertiesId = -1;
- }
d->extraData.cd->parserStatusCast = type.parserStatusCast;
d->extraData.cd->propertyValueSourceCast = type.valueSourceCast;
d->extraData.cd->propertyValueInterceptorCast = type.valueInterceptorCast;
@@ -571,16 +558,8 @@ QQmlType::QQmlType(QQmlTypePrivate *priv)
QQmlType::~QQmlType()
{
- if (d && !d->refCount.deref()) {
- // If attached properties were successfully registered, deregister them.
- // (They may not have been registered if some other type used the same baseMetaObject)
- if (d->regType == CppType && d->extraData.cd->attachedPropertiesType) {
- auto it = QQmlTypePrivate::attachedPropertyIds.find(d->baseMetaObject);
- if (it != QQmlTypePrivate::attachedPropertyIds.end() && *it == d->index)
- QQmlTypePrivate::attachedPropertyIds.erase(it);
- }
+ if (d && !d->refCount.deref())
delete d;
- }
}
QHashedString QQmlType::module() const
@@ -1221,7 +1200,7 @@ int QQmlType::attachedPropertiesId(QQmlEnginePrivate *engine) const
if (!d)
return -1;
if (d->regType == CppType)
- return d->extraData.cd->attachedPropertiesId;
+ return d->extraData.cd->attachedPropertiesType ? d->index : -1;
QQmlType base;
if (d->regType == CompositeType)
@@ -2184,6 +2163,16 @@ QQmlAttachedPropertiesFunc QQmlMetaType::attachedPropertiesFuncById(QQmlEnginePr
return data->types.at(id).attachedPropertiesFunction(engine);
}
+QQmlAttachedPropertiesFunc QQmlMetaType::attachedPropertiesFunc(QQmlEnginePrivate *engine,
+ const QMetaObject *mo)
+{
+ QMutexLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+
+ QQmlType type(data->metaObjectToType.value(mo));
+ return type.attachedPropertiesFunction(engine);
+}
+
QMetaProperty QQmlMetaType::defaultProperty(const QMetaObject *metaObject)
{
int idx = metaObject->indexOfClassInfo("DefaultProperty");