diff options
author | Liang Qi <liang.qi@qt.io> | 2019-01-22 10:35:09 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2019-01-22 11:20:29 +0100 |
commit | 1b4d2741f90d3f4daf79940b9c8713dda0fb7f3d (patch) | |
tree | 40cee4f6af7bf9a5fc87c43f024f417a5d09e18d /src/qml/qml/qqmlmetatype.cpp | |
parent | 536868fad50778ec5bf4c6c7269c721b05d8a2d5 (diff) | |
parent | 84e15a609b37a64baf82ed20f8d4f79474989226 (diff) |
Merge remote-tracking branch 'origin/5.12' into dev
Conflicts:
.qmake.conf
tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
Change-Id: Ic1f5e219a255d0613f7654368a5ce3eccb8f0ee9
Diffstat (limited to 'src/qml/qml/qqmlmetatype.cpp')
-rw-r--r-- | src/qml/qml/qqmlmetatype.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index c05ae27b93..032ee7d6fc 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -497,9 +497,9 @@ QQmlType::QQmlType(QQmlMetaTypeData *data, const QString &elementName, const QQm d->extraData.cd->attachedPropertiesFunc = type.attachedPropertiesFunction; d->extraData.cd->attachedPropertiesType = type.attachedPropertiesMetaObject; if (d->extraData.cd->attachedPropertiesType) { - QHash<const QMetaObject *, int>::Iterator iter = d->attachedPropertyIds.find(d->baseMetaObject); - if (iter == d->attachedPropertyIds.end()) - iter = d->attachedPropertyIds.insert(d->baseMetaObject, d->index); + auto iter = QQmlTypePrivate::attachedPropertyIds.find(d->baseMetaObject); + if (iter == QQmlTypePrivate::attachedPropertyIds.end()) + iter = QQmlTypePrivate::attachedPropertyIds.insert(d->baseMetaObject, d->index); d->extraData.cd->attachedPropertiesId = *iter; } else { d->extraData.cd->attachedPropertiesId = -1; @@ -569,8 +569,16 @@ QQmlType::QQmlType(QQmlTypePrivate *priv) QQmlType::~QQmlType() { - if (d && !d->refCount.deref()) + if (d && !d->refCount.deref()) { + // If attached properties were successfully registered, deregister them. + // (They may not have been registered if some other type used the same baseMetaObject) + if (d->regType == CppType && d->extraData.cd->attachedPropertiesType) { + auto it = QQmlTypePrivate::attachedPropertyIds.find(d->baseMetaObject); + if (it != QQmlTypePrivate::attachedPropertyIds.end() && *it == d->index) + QQmlTypePrivate::attachedPropertyIds.erase(it); + } delete d; + } } QHashedString QQmlType::module() const |