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/qqmlcustomparser.cpp | |
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/qqmlcustomparser.cpp')
-rw-r--r-- | src/qml/qml/qqmlcustomparser.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/qml/qml/qqmlcustomparser.cpp b/src/qml/qml/qqmlcustomparser.cpp index 0b0bbef795..ecdaf41523 100644 --- a/src/qml/qml/qqmlcustomparser.cpp +++ b/src/qml/qml/qqmlcustomparser.cpp @@ -132,7 +132,7 @@ int QQmlCustomParser::evaluateEnum(const QByteArray& script, bool *ok) const if (scope != QLatin1String("Qt")) { if (imports.isNull()) return -1; - QQmlType *type = 0; + QQmlType type; if (imports.isT1()) { imports.asT1()->resolveType(scope, &type, 0, 0, 0); @@ -142,7 +142,7 @@ int QQmlCustomParser::evaluateEnum(const QByteArray& script, bool *ok) const type = result.type; } - return type ? type->enumValue(engine, QHashedCStringRef(enumValue.constData(), enumValue.length()), ok) : -1; + return type.enumValue(engine, QHashedCStringRef(enumValue.constData(), enumValue.length()), ok); } const QMetaObject *mo = StaticQtMetaObject::get(); @@ -163,12 +163,10 @@ const QMetaObject *QQmlCustomParser::resolveType(const QString& name) const { if (!imports.isT1()) return nullptr; - QQmlType *qmltype = 0; + QQmlType qmltype; if (!imports.asT1()->resolveType(name, &qmltype, 0, 0, 0)) return nullptr; - if (!qmltype) - return nullptr; - return qmltype->metaObject(); + return qmltype.metaObject(); } QT_END_NAMESPACE |