diff options
author | Kevin Ottens <kevin.ottens@kdab.com> | 2017-02-16 19:49:50 +0100 |
---|---|---|
committer | Kevin Ottens <kevin.ottens@kdab.com> | 2017-02-17 07:57:37 +0000 |
commit | 06ad843b225bda9713507280347ee13be87c7882 (patch) | |
tree | 554b766a0c5686f0e950f857f6b75ec6fd865b48 /src/qml/qml/qqml.h | |
parent | f048d9913d3a552c85f12df4cf1895989f828e17 (diff) |
Add missing qmlRegisterExtendedUncreatableType variant
We need another qmlRegisterExtendedUncreatableType allowing to pass the
metaObjectRevision as third parameter. Otherwise extended uncreatable
types can't use for instance REVISION in their properties.
This is missing for some of the Qt 3D types for which we are cleaning up
the versioning for 5.9.0 and which fall in this category.
Change-Id: I20ebec339814d7f43cc4b2b58090406b0d5fb97e
Task-Id: QTBUG-58895
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/qml/qqml.h')
-rw-r--r-- | src/qml/qml/qqml.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h index f0973338ea..ddb4af0b81 100644 --- a/src/qml/qml/qqml.h +++ b/src/qml/qml/qqml.h @@ -238,6 +238,44 @@ int qmlRegisterExtendedUncreatableType(const char *uri, int versionMajor, int ve return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type); } +template<typename T, typename E, int metaObjectRevision> +int qmlRegisterExtendedUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason) +{ + QML_GETTYPENAMES + + QQmlAttachedPropertiesFunc attached = QQmlPrivate::attachedPropertiesFunc<E>(); + const QMetaObject * attachedMetaObject = QQmlPrivate::attachedPropertiesMetaObject<E>(); + if (!attached) { + attached = QQmlPrivate::attachedPropertiesFunc<T>(); + attachedMetaObject = QQmlPrivate::attachedPropertiesMetaObject<T>(); + } + + QQmlPrivate::RegisterType type = { + 1, + + qRegisterNormalizedMetaType<T *>(pointerName.constData()), + qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()), + 0, + Q_NULLPTR, + reason, + + uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject, + + attached, + attachedMetaObject, + + QQmlPrivate::StaticCastSelector<T,QQmlParserStatus>::cast(), + QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(), + QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(), + + QQmlPrivate::createParent<E>, &E::staticMetaObject, + + Q_NULLPTR, + metaObjectRevision + }; + + return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type); +} Q_QML_EXPORT int qmlRegisterUncreatableMetaObject(const QMetaObject &staticMetaObject, const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason); |