diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-06-23 13:20:23 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2017-08-02 16:32:43 +0000 |
commit | 49a11e882059ee1729f776722e085dd21d378c36 (patch) | |
tree | 1b0fe9a471766d97d03602502acc57c00df93b36 /src/qml/qml/qqmltypenamecache_p.h | |
parent | 97165444ac6954766d53c3eb62eb1614644c7264 (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/qqmltypenamecache_p.h')
-rw-r--r-- | src/qml/qml/qqmltypenamecache_p.h | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/qml/qml/qqmltypenamecache_p.h b/src/qml/qml/qqmltypenamecache_p.h index 7cdcbe91b6..0705166ec2 100644 --- a/src/qml/qml/qqmltypenamecache_p.h +++ b/src/qml/qml/qqmltypenamecache_p.h @@ -78,13 +78,13 @@ public: struct Result { inline Result(); inline Result(const void *importNamespace); - inline Result(QQmlType *type); + inline Result(const QQmlType &type); inline Result(int scriptIndex); inline Result(const Result &); inline bool isValid() const; - QQmlType *type; + QQmlType type; const void *importNamespace; int scriptIndex; }; @@ -132,9 +132,8 @@ private: { QUrl *url = urls.value(key); if (url) { - QQmlType *type = QQmlMetaType::qmlType(*url); - if (type) - return Result(type); + QQmlType type = QQmlMetaType::qmlType(*url); + return Result(type); } return Result(); @@ -145,7 +144,8 @@ private: { QVector<QQmlTypeModuleVersion>::const_iterator end = modules.constEnd(); for (QVector<QQmlTypeModuleVersion>::const_iterator it = modules.constBegin(); it != end; ++it) { - if (QQmlType *type = it->type(key)) + QQmlType type = it->type(key); + if (type.isValid()) return Result(type); } @@ -160,22 +160,22 @@ private: }; QQmlTypeNameCache::Result::Result() -: type(0), importNamespace(0), scriptIndex(-1) +: importNamespace(0), scriptIndex(-1) { } QQmlTypeNameCache::Result::Result(const void *importNamespace) -: type(0), importNamespace(importNamespace), scriptIndex(-1) +: importNamespace(importNamespace), scriptIndex(-1) { } -QQmlTypeNameCache::Result::Result(QQmlType *type) +QQmlTypeNameCache::Result::Result(const QQmlType &type) : type(type), importNamespace(0), scriptIndex(-1) { } QQmlTypeNameCache::Result::Result(int scriptIndex) -: type(0), importNamespace(0), scriptIndex(scriptIndex) +: importNamespace(0), scriptIndex(scriptIndex) { } @@ -186,7 +186,7 @@ QQmlTypeNameCache::Result::Result(const Result &o) bool QQmlTypeNameCache::Result::isValid() const { - return type || importNamespace || scriptIndex != -1; + return type.isValid() || importNamespace || scriptIndex != -1; } QQmlTypeNameCache::Import::Import() |