From 8d0b649c6b6ebf64dd4f644a5a2b3b1fa34e57c9 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 4 Feb 2019 09:25:31 +0100 Subject: Tighten the interface of QQmlTypeModule No other classes really need direct access to QQmlTypeModulePrivate. Adding or removing types, as well as lookup of types needs to be protected by a mutex, as that can happen from multiple threads. However, we don't need to acquire the global type registration mutex in order to change the internals of some QQmlTypeModule. Rather, each type module gets its own mutex. The minimum and maximum versions as well as the "locked" property can be handled with atomic integers as they only ever move in one direction. The module and majorVersion properties are constant over the life time of the object. Therefore they don't need any locking. Task-number: QTBUG-73271 Change-Id: I23fe7dcaf521ccecaaaf19c1fb0436e109c42f03 Reviewed-by: Lars Knoll --- src/qml/qml/qqmltypemodule_p.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/qml/qml/qqmltypemodule_p.h') diff --git a/src/qml/qml/qqmltypemodule_p.h b/src/qml/qml/qqmltypemodule_p.h index 6107988a70..b84a91b5db 100644 --- a/src/qml/qml/qqmltypemodule_p.h +++ b/src/qml/qml/qqmltypemodule_p.h @@ -72,9 +72,19 @@ class QQmlTypeModulePrivate; class QQmlTypeModule { public: + QQmlTypeModule(const QString &uri = QString(), int majorVersion = 0); + ~QQmlTypeModule(); + + void add(QQmlTypePrivate *); + void remove(const QQmlTypePrivate *type); + + bool isLocked() const; + void lock(); + QString module() const; int majorVersion() const; + void addMinorVersion(int minorVersion); int minimumMinorVersion() const; int maximumMinorVersion() const; @@ -83,17 +93,7 @@ public: void walkCompositeSingletons(const std::function &callback) const; - QQmlTypeModulePrivate *priv() { return d; } private: - //Used by register functions and creates the QQmlTypeModule for them - friend QQmlTypeModule *getTypeModule(const QHashedString &uri, int majorVersion, QQmlMetaTypeData *data); - friend void addTypeToData(QQmlTypePrivate *type, QQmlMetaTypeData *data); - friend struct QQmlMetaTypeData; - friend class QQmlMetaType; - friend class QQmlTypeModulePrivate; - - QQmlTypeModule(); - ~QQmlTypeModule(); QQmlTypeModulePrivate *d; }; -- cgit v1.2.3