aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqml.h
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-05-26 23:04:40 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-05-26 23:04:41 +0200
commit3ecdd85b2c7b8d56c4fd1a12a6cbaab663024ddb (patch)
tree255dae23f41c011b28167efe4ac8035384ef0346 /src/qml/qml/qqml.h
parentfb4c12a9db86a4b886058cc937c3c20b798bd2e2 (diff)
parent3e716029ae61bf4c7bb33643ac331156e70e34f1 (diff)
Merge remote-tracking branch 'origin/5.12' into 5.13
Diffstat (limited to 'src/qml/qml/qqml.h')
-rw-r--r--src/qml/qml/qqml.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h
index 42cf723284..6bd66464b5 100644
--- a/src/qml/qml/qqml.h
+++ b/src/qml/qml/qqml.h
@@ -606,9 +606,12 @@ Q_QML_EXPORT void qmlRegisterModule(const char *uri, int versionMajor, int versi
template<typename T>
QObject *qmlAttachedPropertiesObject(const QObject *obj, bool create = true)
{
- QObject *mutableObj = const_cast<QObject *>(obj);
- return qmlAttachedPropertiesObject(
- mutableObj, qmlAttachedPropertiesFunction(mutableObj, &T::staticMetaObject), create);
+ // We don't need a concrete object to resolve the function. As T is a C++ type, it and all its
+ // super types should be registered as CppType (or not at all). We only need the object and its
+ // QML engine to resolve composite types. Therefore, the function is actually a static property
+ // of the C++ type system and we can cache it here for improved performance on further lookups.
+ static const auto func = qmlAttachedPropertiesFunction(nullptr, &T::staticMetaObject);
+ return qmlAttachedPropertiesObject(const_cast<QObject *>(obj), func, create);
}
Q_QML_EXPORT void qmlRegisterBaseTypes(const char *uri, int versionMajor, int versionMinor);