diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-04-26 08:23:19 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-06-04 15:26:18 +0200 |
commit | ea442c62a2390b7091ebf50e922cfeee49c8d3dc (patch) | |
tree | 124b12462fd9ecb2de8e10a48236b4a473a86749 /src/qmlmodels/qqmladaptormodel.cpp | |
parent | aebec92445c7c8427248f8f08d63a1ec24745ebb (diff) |
QQmlPropertyCache: Guarantee 1:1 relationship to meta object
The QQmlPropertyCache ctor that just takes a QMetaObject is really
dangerous. It misbehaves for anything but plain QObject. Remove it.
Also, realize that we never want to update a property cache
"recursively". That is, each property cache maps exactly one metaobject.
We cannot cover multiple metaobjects with the same property cache.
Finally, any property caches constructed dynamically must not be
recorded in the type registry. These caches are not comparable to
anything else. Introduce a special method to create them.
Fixes: QTBUG-102454
Change-Id: I47a1ff0f467e9444ff9f581ffcdf0a8b5730b0b8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit f7f6e140947582026d08a68421052e6ac7b997e4)
Diffstat (limited to 'src/qmlmodels/qqmladaptormodel.cpp')
-rw-r--r-- | src/qmlmodels/qqmladaptormodel.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/qmlmodels/qqmladaptormodel.cpp b/src/qmlmodels/qqmladaptormodel.cpp index ebedbad596..65feb5c6cf 100644 --- a/src/qmlmodels/qqmladaptormodel.cpp +++ b/src/qmlmodels/qqmladaptormodel.cpp @@ -549,7 +549,8 @@ public: metaObject.reset(builder.toMetaObject()); *static_cast<QMetaObject *>(this) = *metaObject; - propertyCache.adopt(new QQmlPropertyCache(metaObject.data(), model.modelItemRevision)); + propertyCache = QQmlPropertyCache::createStandalone( + metaObject.data(), model.modelItemRevision); } }; @@ -683,8 +684,8 @@ public: { VDMListDelegateDataType *dataType = const_cast<VDMListDelegateDataType *>(this); if (!propertyCache) { - dataType->propertyCache.adopt(new QQmlPropertyCache( - &QQmlDMListAccessorData::staticMetaObject, model.modelItemRevision)); + dataType->propertyCache = QQmlPropertyCache::createStandalone( + &QQmlDMListAccessorData::staticMetaObject, model.modelItemRevision); } return new QQmlDMListAccessorData( |