diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-06-11 01:01:10 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-06-11 11:28:44 +0200 |
commit | 10e3b24c02cd1c22c7df0f350f229625e13faeae (patch) | |
tree | e9f02181e47156e9c8652e0c5dba15bbdcb97e5a /src/qml/qml/qqml.h | |
parent | 8733a8762c2db473d3a39d1f01c09156c04e3772 (diff) | |
parent | ac402fa6d99eeb519a9cc23b028358dfb6df4d82 (diff) |
Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
src/qml/jsruntime/qv4value_p.h
src/qml/qml/qqmlmetatype.cpp
src/qml/qml/qqmltypewrapper.cpp
src/quick/items/qquicktableview.cpp
Change-Id: I684f8e01a711580512848bf1253f39b39fcbf4c7
Diffstat (limited to 'src/qml/qml/qqml.h')
-rw-r--r-- | src/qml/qml/qqml.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h index 7b3f89e943..f84a1b2109 100644 --- a/src/qml/qml/qqml.h +++ b/src/qml/qml/qqml.h @@ -608,9 +608,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); } inline int qmlRegisterSingletonType(const char *uri, int versionMajor, int versionMinor, const char *typeName, |