diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2025-11-18 10:34:07 +0100 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2025-11-27 11:55:59 +0100 |
| commit | 945e3faa20379cfd753ce3c6037806ba4319f98d (patch) | |
| tree | f16cd690c2aa6b5d8a2bc6dff43459df4fb33274 /src | |
| parent | 9d60768a12376e67e90ab23ad64881bb85daeed7 (diff) | |
QmlModels: Rename QQmlDelegateModelItem::isReferenced()
Since there are two kinds of references, we need to be more specific.
Task-number: QTBUG-141963
Change-Id: I8583b91fab62abec49a5f71652e8c04fa8906b7b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src')
| -rw-r--r-- | src/qmlmodels/qqmldelegatemodel.cpp | 14 | ||||
| -rw-r--r-- | src/qmlmodels/qqmldelegatemodel_p_p.h | 2 | ||||
| -rw-r--r-- | src/qmlmodels/qqmltableinstancemodel.cpp | 10 |
3 files changed, 13 insertions, 13 deletions
diff --git a/src/qmlmodels/qqmldelegatemodel.cpp b/src/qmlmodels/qqmldelegatemodel.cpp index 8025c0593c..61171ba8a9 100644 --- a/src/qmlmodels/qqmldelegatemodel.cpp +++ b/src/qmlmodels/qqmldelegatemodel.cpp @@ -244,7 +244,7 @@ QQmlDelegateModel::~QQmlDelegateModel() cacheItem->clearIncubationTask(); } - if (!cacheItem->isReferenced()) + if (!cacheItem->isScriptReferenced()) delete cacheItem; } } @@ -682,7 +682,7 @@ void QQmlDelegateModel::cancel(int index) d->emitDestroyingItem(object); } } - if (!cacheItem->isReferenced() && !cacheItem->object()) { + if (!cacheItem->isScriptReferenced() && !cacheItem->object()) { d->m_compositor.clearFlags( Compositor::Cache, it.cacheIndex(), 1, Compositor::CacheFlag); d->m_cache.removeAt(it.cacheIndex()); @@ -1217,7 +1217,7 @@ void QQmlDelegateModelPrivate::incubatorStatusChanged(QQDMIncubationTask *incuba emitDestroyingItem(object); cacheItem->destroyObject(); - if (!cacheItem->isReferenced()) { + if (!cacheItem->isScriptReferenced()) { removeCacheItem(cacheItem); delete cacheItem; } @@ -1369,7 +1369,7 @@ QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, QQ if (cacheItem->objectRef() > 0) cacheItem->releaseObject(); - if (!cacheItem->isReferenced()) { + if (!cacheItem->isScriptReferenced()) { // If it had an object and no incubationTask we would have returned above. // If it had an incubationTask it would be referenced, no matter if it has an object. @@ -1753,7 +1753,7 @@ void QQmlDelegateModelPrivate::itemsRemoved( else emitDestroyingItem(object); } - if (!cacheItem->isReferenced() + if (!cacheItem->isScriptReferenced() && !cacheItem->object() && !remove.inGroup(Compositor::Persisted)) { m_compositor.clearFlags(Compositor::Cache, cacheIndex, 1, Compositor::CacheFlag); @@ -2537,7 +2537,7 @@ QQmlDelegateModelItem::~QQmlDelegateModelItem() void QQmlDelegateModelItem::dispose() { - if (isReferenced() || m_object) + if (isScriptReferenced() || m_object) return; if (QQmlDelegateModel *delegateModel = m_metaType->delegateModel()) @@ -3456,7 +3456,7 @@ void QQmlDelegateModelGroup::resolve(QQmlV4FunctionPtr args) Q_ASSERT(model->m_cache.size() == model->m_compositor.count(Compositor::Cache)); - if (!cacheItem->isReferenced() && !cacheItem->object()) { + if (!cacheItem->isScriptReferenced() && !cacheItem->object()) { Q_ASSERT(toIt.cacheIndex() == model->m_cache.indexOf(cacheItem)); model->m_cache.removeAt(toIt.cacheIndex()); model->m_compositor.clearFlags( diff --git a/src/qmlmodels/qqmldelegatemodel_p_p.h b/src/qmlmodels/qqmldelegatemodel_p_p.h index fc2011dbb4..579064f6d9 100644 --- a/src/qmlmodels/qqmldelegatemodel_p_p.h +++ b/src/qmlmodels/qqmldelegatemodel_p_p.h @@ -162,7 +162,7 @@ public: bool isObjectReferenced() const { return m_objectRef != 0 || (m_groups & Compositor::PersistedFlag); } void childContextObjectDestroyed(QObject *childContextObject); - bool isReferenced() const { + bool isScriptReferenced() const { return m_scriptRef || m_incubationTask || ((m_groups & Compositor::UnresolvedFlag) && (m_groups & Compositor::GroupMask)); diff --git a/src/qmlmodels/qqmltableinstancemodel.cpp b/src/qmlmodels/qqmltableinstancemodel.cpp index e81251265f..5cd5d4be15 100644 --- a/src/qmlmodels/qqmltableinstancemodel.cpp +++ b/src/qmlmodels/qqmltableinstancemodel.cpp @@ -156,7 +156,7 @@ QObject *QQmlTableInstanceModel::object(int index, QQmlIncubator::IncubationMode // should be no object references either. And there should also not be any internal script // refs at this point. So we delete the model item. Q_ASSERT(!modelItem->isObjectReferenced()); - Q_ASSERT(!modelItem->isReferenced()); + Q_ASSERT(!modelItem->isScriptReferenced()); m_modelItems.remove(modelItem->modelIndex()); delete modelItem; return nullptr; @@ -174,7 +174,7 @@ QQmlInstanceModel::ReleaseFlags QQmlTableInstanceModel::release(QObject *object, if (!modelItem->releaseObject()) return QQmlDelegateModel::Referenced; - if (modelItem->isReferenced()) { + if (modelItem->isScriptReferenced()) { // We still have an internal reference to this object, which means that we are told to release an // object while the createdItem signal for it is still on the stack. This can happen when objects // are e.g delivered async, and the user flicks back and forth quicker than the loading can catch @@ -217,7 +217,7 @@ void QQmlTableInstanceModel::dispose(QObject *object) // The item is not referenced by anyone Q_ASSERT(!modelItem->isObjectReferenced()); - Q_ASSERT(!modelItem->isReferenced()); + Q_ASSERT(!modelItem->isScriptReferenced()); // Ensure that the object was incubated by this QQmlTableInstanceModel Q_ASSERT(m_modelItems.contains(modelItem->modelIndex())); Q_ASSERT(m_modelItems[modelItem->modelIndex()]->object() == object); @@ -362,7 +362,7 @@ void QQmlTableInstanceModel::incubatorStatusChanged(QQmlTableInstanceModelIncuba qWarning() << "Error incubating delegate:" << incubationTask->errors(); } - if (!modelItem->isReferenced() && !modelItem->isObjectReferenced()) { + if (!modelItem->isScriptReferenced() && !modelItem->isObjectReferenced()) { // We have no internal reference to the model item, and the view has no // reference to the incubated object. So just delete the model item. // Note that being here means that the object was incubated _async_ @@ -374,7 +374,7 @@ void QQmlTableInstanceModel::incubatorStatusChanged(QQmlTableInstanceModelIncuba emit destroyingItem(object); } - Q_ASSERT(!modelItem->isReferenced()); + Q_ASSERT(!modelItem->isScriptReferenced()); deleteModelItemLater(modelItem); } |
