diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-04-23 13:28:58 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-04-26 09:56:39 +0000 |
commit | 1a3447a0405831fa5502247f9eaff48afdfe0dea (patch) | |
tree | f40e71aadfda2ddc251ebab18a983a80b5d9b33f /src/qml/qml/qqmlengine.cpp | |
parent | 78be6b2aa4da54cb41ed60a31abfb7312fb44c9a (diff) |
Clean up manual reference of QQmlTypeData and QQmlPropertyCache
We have a few places in the type loader where we do adventurous manual
reference counting, where getType() returns a raw pointer that has been
addref()'ed and then sometimes somehow we call release() later. Commit
0b394e30bba4f6bb7e6f7dbe5585a2e15aa0f21d is an example of where this can
easily go wrong. As a consequence and also in preparation for future
work on the type loader, this patch starts replacing the manual
reference counting there.
Changing the return type from QQmlTypeData *getType() to a
QQmlRefPointer<> itself is not sufficient though, as the implicit
operator T*() will still allow the caller to store the result as a raw
pointer. Therefore this patch removes the "unsafe" implicit extraction
operator.
As a result of that change, other types that are sometimes stored in
QQmlRefPointer are also affected and their usage needs to be adapted
to QQmlRefPointer usage or manual raw pointer extraction with .data().
Change-Id: I18fd40634047f13196a237f4e6766cbef3bfbea2
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlengine.cpp')
-rw-r--r-- | src/qml/qml/qqmlengine.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index b72e07d97b..1ae39423e9 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -1706,7 +1706,7 @@ void QQmlData::NotifyList::layout() todo = nullptr; } -void QQmlData::deferData(int objectIndex, QV4::CompiledData::CompilationUnit *compilationUnit, QQmlContextData *context) +void QQmlData::deferData(int objectIndex, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, QQmlContextData *context) { QQmlData::DeferredData *deferData = new QQmlData::DeferredData; deferData->deferredIdx = objectIndex; @@ -2273,7 +2273,7 @@ QQmlMetaObject QQmlEnginePrivate::rawMetaObjectForType(int t) const Locker locker(this); auto iter = m_compositeTypes.constFind(t); if (iter != m_compositeTypes.cend()) { - return QQmlMetaObject((*iter)->rootPropertyCache()); + return QQmlMetaObject((*iter)->rootPropertyCache().data()); } else { QQmlType type = QQmlMetaType::qmlType(t); return QQmlMetaObject(type.baseMetaObject()); @@ -2285,7 +2285,7 @@ QQmlMetaObject QQmlEnginePrivate::metaObjectForType(int t) const Locker locker(this); auto iter = m_compositeTypes.constFind(t); if (iter != m_compositeTypes.cend()) { - return QQmlMetaObject((*iter)->rootPropertyCache()); + return QQmlMetaObject((*iter)->rootPropertyCache().data()); } else { QQmlType type = QQmlMetaType::qmlType(t); return QQmlMetaObject(type.metaObject()); @@ -2297,7 +2297,7 @@ QQmlPropertyCache *QQmlEnginePrivate::propertyCacheForType(int t) Locker locker(this); auto iter = m_compositeTypes.constFind(t); if (iter != m_compositeTypes.cend()) { - return (*iter)->rootPropertyCache(); + return (*iter)->rootPropertyCache().data(); } else { QQmlType type = QQmlMetaType::qmlType(t); locker.unlock(); @@ -2310,7 +2310,7 @@ QQmlPropertyCache *QQmlEnginePrivate::rawPropertyCacheForType(int t, int minorVe Locker locker(this); auto iter = m_compositeTypes.constFind(t); if (iter != m_compositeTypes.cend()) { - return (*iter)->rootPropertyCache(); + return (*iter)->rootPropertyCache().data(); } else { QQmlType type = QQmlMetaType::qmlType(t); locker.unlock(); |