aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmltypemodule_p.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-12-02 12:15:07 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-12-03 08:20:52 +0100
commit8762e2fb681acb2947d2dd7243da12e546582723 (patch)
tree494fe7a9c78498988b2639cc2149e5b4edad07c1 /src/qml/qml/qqmltypemodule_p.h
parent05bf2f293a952eac7a41279815bf3480aa067586 (diff)
QQmlTypeNameCache: Unify querying for types
Template all of the code and make sure the different query variants do the same work. There is no reason not to query the namespaced imports if we are passed a different string type as parameter. If we want to skip the namespaced imports, that is a separate parameter. This needs to be picked to 6.2 as precondition for fixing AOTCompiledContext::initLoadAttachedLookup. We need to pass a QQmlImport::RecursionRestriction when querying by QHashedStringRef. Pick-to: 6.2 Change-Id: I98aecc7775036728668cc93f550aa73fdefafe9a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmltypemodule_p.h')
-rw-r--r--src/qml/qml/qqmltypemodule_p.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/qml/qml/qqmltypemodule_p.h b/src/qml/qml/qqmltypemodule_p.h
index c6dae7ef55..37b9a32b90 100644
--- a/src/qml/qml/qqmltypemodule_p.h
+++ b/src/qml/qml/qqmltypemodule_p.h
@@ -53,6 +53,7 @@
#include <QtQml/qtqmlglobal.h>
#include <QtQml/private/qstringhash_p.h>
+#include <QtQml/private/qqmltype_p.h>
#include <QtCore/qmutex.h>
#include <QtCore/qstring.h>
#include <QtCore/qversionnumber.h>
@@ -114,12 +115,24 @@ public:
quint8 minimumMinorVersion() const { return m_minMinorVersion.loadRelaxed(); }
quint8 maximumMinorVersion() const { return m_maxMinorVersion.loadRelaxed(); }
- QQmlType type(const QHashedStringRef &, QTypeRevision version) const;
- QQmlType type(const QV4::String *, QTypeRevision version) const;
+ QQmlType type(const QHashedStringRef &name, QTypeRevision version) const
+ {
+ QMutexLocker lock(&m_mutex);
+ return findType(m_typeHash.value(name), version);
+ }
+
+ QQmlType type(const QV4::String *name, QTypeRevision version) const
+ {
+ QMutexLocker lock(&m_mutex);
+ return findType(m_typeHash.value(name), version);
+ }
void walkCompositeSingletons(const std::function<void(const QQmlType &)> &callback) const;
private:
+ static Q_QML_PRIVATE_EXPORT QQmlType findType(
+ const QList<QQmlTypePrivate *> *types, QTypeRevision version);
+
const QString m_module;
const quint8 m_majorVersion = 0;