aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmltypemodule_p.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-02-04 09:25:31 +0100
committerUlf Hermann <ulf.hermann@qt.io>2019-02-07 13:49:26 +0000
commit8d0b649c6b6ebf64dd4f644a5a2b3b1fa34e57c9 (patch)
tree41fd801a6949cd59374e81b8a3c0939c25118bc2 /src/qml/qml/qqmltypemodule_p.h
parent77ca9599418806733322b6be55283098cea383a4 (diff)
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 <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/qml/qqmltypemodule_p.h')
-rw-r--r--src/qml/qml/qqmltypemodule_p.h20
1 files changed, 10 insertions, 10 deletions
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<void(const QQmlType &)> &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;
};