aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlmetatype_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-06-23 13:20:23 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2017-08-02 16:32:43 +0000
commit49a11e882059ee1729f776722e085dd21d378c36 (patch)
tree1b0fe9a471766d97d03602502acc57c00df93b36 /src/qml/qml/qqmlmetatype_p.h
parent97165444ac6954766d53c3eb62eb1614644c7264 (diff)
Use QQmlType by value
QQmlType is now refcounted, and we need to use it by value, to control it's lifetime properly. This is required, so we can clean up the QQmlMetaTypeData cache on engine destruction and with trimComponentCache() Task-number: QTBUG-61536 Change-Id: If86391c86ea20a646ded7c9925d8f743f628fb91 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlmetatype_p.h')
-rw-r--r--src/qml/qml/qqmlmetatype_p.h52
1 files changed, 33 insertions, 19 deletions
diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h
index 08198340f3..d17172a917 100644
--- a/src/qml/qml/qqmlmetatype_p.h
+++ b/src/qml/qml/qqmlmetatype_p.h
@@ -77,17 +77,17 @@ class Q_QML_PRIVATE_EXPORT QQmlMetaType
{
public:
static QList<QString> qmlTypeNames();
- static QList<QQmlType*> qmlTypes();
- static QList<QQmlType*> qmlSingletonTypes();
- static QList<QQmlType*> qmlAllTypes();
-
- static QQmlType *qmlType(const QString &qualifiedName, int, int);
- static QQmlType *qmlType(const QHashedStringRef &name, const QHashedStringRef &module, int, int);
- static QQmlType *qmlType(const QMetaObject *);
- static QQmlType *qmlType(const QMetaObject *metaObject, const QHashedStringRef &module, int version_major, int version_minor);
- static QQmlType *qmlType(int);
- static QQmlType *qmlType(const QUrl &url, bool includeNonFileImports = false);
- static QQmlType *qmlTypeFromIndex(int);
+ static QList<QQmlType *> qmlTypes();
+ static QList<QQmlType> qmlSingletonTypes();
+ static QList<QQmlType *> qmlAllTypes();
+
+ static QQmlType qmlType(const QString &qualifiedName, int, int);
+ static QQmlType qmlType(const QHashedStringRef &name, const QHashedStringRef &module, int, int);
+ static QQmlType qmlType(const QMetaObject *);
+ static QQmlType qmlType(const QMetaObject *metaObject, const QHashedStringRef &module, int version_major, int version_minor);
+ static QQmlType qmlType(int);
+ static QQmlType qmlType(const QUrl &url, bool includeNonFileImports = false);
+ static QQmlType qmlTypeFromIndex(int);
static QMetaProperty defaultProperty(const QMetaObject *);
static QMetaProperty defaultProperty(QObject *);
@@ -144,7 +144,16 @@ public:
explicit QQmlType(QQmlTypePrivate *priv);
~QQmlType();
+ // ### get rid of these two again
+ QQmlType(QQmlType *otherPointer);
+ QQmlType &operator =(QQmlType *otherPointer);
+
+ bool operator ==(const QQmlType &other) const {
+ return d == other.d;
+ }
+
bool isValid() const { return d != 0; }
+ const QQmlTypePrivate *key() const { return d; }
QByteArray typeName() const;
QString qmlTypeName() const;
@@ -229,8 +238,8 @@ public:
static void refHandle(QQmlTypePrivate *priv);
static void derefHandle(QQmlTypePrivate *priv);
private:
- QQmlType *superType() const;
- QQmlType *resolveCompositeBaseType(QQmlEnginePrivate *engine) const;
+ QQmlType superType() const;
+ QQmlType resolveCompositeBaseType(QQmlEnginePrivate *engine) const;
int resolveCompositeEnumValue(QQmlEnginePrivate *engine, const QString &name, bool *ok) const;
friend class QQmlTypePrivate;
friend struct QQmlMetaTypeData;
@@ -250,6 +259,7 @@ private:
friend int registerCompositeType(const QQmlPrivate::RegisterCompositeType &);
friend int registerCompositeSingletonType(const QQmlPrivate::RegisterCompositeSingletonType &);
friend int registerQmlUnitCacheHook(const QQmlPrivate::RegisterQmlUnitCacheHook &);
+ friend uint qHash(const QQmlType &t, uint seed);
friend Q_QML_EXPORT void qmlClearTypeRegistrations();
QQmlType(int, const QQmlPrivate::RegisterInterface &);
QQmlType(int, const QString &, const QQmlPrivate::RegisterSingletonType &);
@@ -260,6 +270,12 @@ private:
QQmlTypePrivate *d;
};
+Q_DECLARE_TYPEINFO(QQmlMetaType, Q_MOVABLE_TYPE);
+
+
+inline uint qHash(const QQmlType &t, uint seed = 0) { return qHash(reinterpret_cast<quintptr>(t.d), seed); }
+
+
class QQmlTypeModulePrivate;
class QQmlTypeModule
{
@@ -270,10 +286,8 @@ public:
int minimumMinorVersion() const;
int maximumMinorVersion() const;
- QQmlType *type(const QHashedStringRef &, int) const;
- QQmlType *type(const QV4::String *, int) const;
-
- QList<QQmlType*> singletonTypes(int) const;
+ QQmlType type(const QHashedStringRef &, int) const;
+ QQmlType type(const QV4::String *, int) const;
private:
//Used by register functions and creates the QQmlTypeModule for them
@@ -299,8 +313,8 @@ public:
QQmlTypeModule *module() const;
int minorVersion() const;
- QQmlType *type(const QHashedStringRef &) const;
- QQmlType *type(const QV4::String *) const;
+ QQmlType type(const QHashedStringRef &) const;
+ QQmlType type(const QV4::String *) const;
private:
QQmlTypeModule *m_module;