diff options
Diffstat (limited to 'src/qml/qml/qqmlmetatype.cpp')
-rw-r--r-- | src/qml/qml/qqmlmetatype.cpp | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index 32f281b4f2..09df23de51 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -76,6 +76,8 @@ public: const QQmlMetaTypeData *operator->() const { return data; } operator const QQmlMetaTypeData *() const { return data; } + bool isValid() const { return data != nullptr; } + private: QMutexLocker locker; LockedData *data = nullptr; @@ -143,12 +145,6 @@ static QQmlTypePrivate *createQQmlType(QQmlMetaTypeData *data, const QString &el d->baseMetaObject = type.metaObject; d->extraData.cd->attachedPropertiesFunc = type.attachedPropertiesFunction; d->extraData.cd->attachedPropertiesType = type.attachedPropertiesMetaObject; - if (d->extraData.cd->attachedPropertiesType) { - d->extraData.cd->attachedPropertiesId = data->attachedPropertyId(d->baseMetaObject, - d->index); - } else { - d->extraData.cd->attachedPropertiesId = -1; - } d->extraData.cd->parserStatusCast = type.parserStatusCast; d->extraData.cd->propertyValueSourceCast = type.valueSourceCast; d->extraData.cd->propertyValueInterceptorCast = type.valueInterceptorCast; @@ -599,19 +595,6 @@ void QQmlMetaType::registerUndeletableType(const QQmlType &dtype) data->undeletableTypes.insert(dtype); } -int QQmlMetaType::registerAttachedPropertyId(const QMetaObject *metaObject, int index) -{ - QQmlMetaTypeDataPtr data; - return data->attachedPropertyId(metaObject, index); -} - -bool QQmlMetaType::unregisterAttachedPropertyId(const QMetaObject *metaObject, int index) -{ - QQmlMetaTypeDataPtr data; - // This is run from the QQmlType dtor. QQmlTypes in user code can outlive QQmlMetaTypeData. - return data ? data->removeAttachedPropertyId(metaObject, index) : false; -} - static bool namespaceContainsRegistrations(const QQmlMetaTypeData *data, const QString &uri, int majorVersion) { @@ -916,6 +899,7 @@ int QQmlMetaType::listType(int id) return 0; } +#if QT_DEPRECATED_SINCE(5, 14) int QQmlMetaType::attachedPropertiesFuncId(QQmlEnginePrivate *engine, const QMetaObject *mo) { QQmlMetaTypeDataPtr data; @@ -937,6 +921,16 @@ QQmlAttachedPropertiesFunc QQmlMetaType::attachedPropertiesFuncById(QQmlEnginePr QQmlMetaTypeDataPtr data; return data->types.at(id).attachedPropertiesFunction(engine); } +#endif + +QQmlAttachedPropertiesFunc QQmlMetaType::attachedPropertiesFunc(QQmlEnginePrivate *engine, + const QMetaObject *mo) +{ + QQmlMetaTypeDataPtr data; + + QQmlType type(data->metaObjectToType.value(mo)); + return type.attachedPropertiesFunction(engine); +} QMetaProperty QQmlMetaType::defaultProperty(const QMetaObject *metaObject) { @@ -1216,6 +1210,10 @@ void QQmlMetaType::freeUnusedTypesAndCaches() { QQmlMetaTypeDataPtr data; + // in case this is being called during program exit, `data` might be destructed already + if (!data.isValid()) + return; + bool deletedAtLeastOneType; do { deletedAtLeastOneType = false; |