aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlmetatype_p.h
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2017-06-26 14:52:22 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2017-08-02 16:33:05 +0000
commit48c09a85ce397979c7e706e3694c879ffe456e09 (patch)
treecc2c437bb35f05cc68ef384ba00b833cfde11033 /src/qml/qml/qqmlmetatype_p.h
parent4d393779e7a6ec09267f40420f39f8dc28ed7aef (diff)
Remove unused types on engine destruction
The QML engine destructor as well as trimComponentCache() do now clean out unused composite types that the engine registered internally. This helps avoid 'static' leaks, when more and more types would get registered by the engine. Task-number: QTBUG-61536 Change-Id: I5b32af4b88fbf626de8c0bfbaedb2285b09e3679 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlmetatype_p.h')
-rw-r--r--src/qml/qml/qqmlmetatype_p.h39
1 files changed, 23 insertions, 16 deletions
diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h
index 0077306a64..c0fbdd5060 100644
--- a/src/qml/qml/qqmlmetatype_p.h
+++ b/src/qml/qml/qqmlmetatype_p.h
@@ -77,6 +77,9 @@ namespace QV4 { struct String; }
class Q_QML_PRIVATE_EXPORT QQmlMetaType
{
public:
+ static QQmlType registerCompositeSingletonType(const QQmlPrivate::RegisterCompositeSingletonType &type);
+ static QQmlType registerCompositeType(const QQmlPrivate::RegisterCompositeType &type);
+
static QList<QString> qmlTypeNames();
static QList<QQmlType> qmlTypes();
static QList<QQmlType> qmlSingletonTypes();
@@ -88,11 +91,12 @@ public:
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 QQmlPropertyCache *propertyCache(const QMetaObject *metaObject);
static QQmlPropertyCache *propertyCache(const QQmlType &type, int minorVersion);
+ static void freeUnusedTypesAndCaches();
+
static QMetaProperty defaultProperty(const QMetaObject *);
static QMetaProperty defaultProperty(QObject *);
static QMetaMethod defaultMethod(const QMetaObject *);
@@ -237,11 +241,6 @@ public:
QQmlTypePrivate *priv() const { return d; }
static void refHandle(QQmlTypePrivate *priv);
static void derefHandle(QQmlTypePrivate *priv);
-private:
- QQmlType superType() const;
- QQmlType resolveCompositeBaseType(QQmlEnginePrivate *engine) const;
- int resolveCompositeEnumValue(QQmlEnginePrivate *engine, const QString &name, bool *ok) const;
- friend class QQmlTypePrivate;
enum RegistrationType {
CppType = 0,
@@ -250,21 +249,28 @@ private:
CompositeType = 3,
CompositeSingletonType = 4
};
+
+private:
+ QQmlType superType() const;
+ QQmlType resolveCompositeBaseType(QQmlEnginePrivate *engine) const;
+ int resolveCompositeEnumValue(QQmlEnginePrivate *engine, const QString &name, bool *ok) const;
+ friend class QQmlTypePrivate;
+
friend QString registrationTypeString(RegistrationType);
friend bool checkRegistration(RegistrationType, QQmlMetaTypeData *, const char *, const QString &, int);
- friend int registerType(const QQmlPrivate::RegisterType &);
- friend int registerSingletonType(const QQmlPrivate::RegisterSingletonType &);
- friend int registerInterface(const QQmlPrivate::RegisterInterface &);
- friend int registerCompositeType(const QQmlPrivate::RegisterCompositeType &);
- friend int registerCompositeSingletonType(const QQmlPrivate::RegisterCompositeSingletonType &);
+ friend QQmlType registerType(const QQmlPrivate::RegisterType &);
+ friend QQmlType registerSingletonType(const QQmlPrivate::RegisterSingletonType &);
+ friend QQmlType registerInterface(const QQmlPrivate::RegisterInterface &);
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 &);
- QQmlType(int, const QString &, const QQmlPrivate::RegisterType &);
- QQmlType(int, const QString &, const QQmlPrivate::RegisterCompositeType &);
- QQmlType(int, const QString &, const QQmlPrivate::RegisterCompositeSingletonType &);
+ friend class QQmlMetaType;
+
+ QQmlType(QQmlMetaTypeData *data, const QQmlPrivate::RegisterInterface &);
+ QQmlType(QQmlMetaTypeData *data, const QString &, const QQmlPrivate::RegisterSingletonType &);
+ QQmlType(QQmlMetaTypeData *data, const QString &, const QQmlPrivate::RegisterType &);
+ QQmlType(QQmlMetaTypeData *data, const QString &, const QQmlPrivate::RegisterCompositeType &);
+ QQmlType(QQmlMetaTypeData *data, const QString &, const QQmlPrivate::RegisterCompositeSingletonType &);
QQmlTypePrivate *d;
};
@@ -288,6 +294,7 @@ public:
QQmlType type(const QHashedStringRef &, int) const;
QQmlType type(const QV4::String *, int) 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);