aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlmodels/qqmltableinstancemodel.cpp
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <[email protected]>2022-11-02 14:07:28 +0100
committerRichard Moe Gustavsen <[email protected]>2022-11-03 01:35:10 +0100
commita92920b97a8c9e1ca816a6b9167e4c41c2e0b603 (patch)
treee9a5813a3e0b1d5adbd531d274497c822b75a87c /src/qmlmodels/qqmltableinstancemodel.cpp
parent43028212ffc4d126ba81928ac051bdb136c057af (diff)
QQmlTableInstanceModel: add some extra asserts
Now that QQuickTableView will start to use more than one QQmlTableInstanceModel (to implement editDelegate), add some extra asserts to ensure that we don't mix up which delegate items were created from which instance model. Change-Id: I0d556542ca5409a963ea05c63b3e33b643192bbd Reviewed-by: Doris Verria <[email protected]>
Diffstat (limited to 'src/qmlmodels/qqmltableinstancemodel.cpp')
-rw-r--r--src/qmlmodels/qqmltableinstancemodel.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/qmlmodels/qqmltableinstancemodel.cpp b/src/qmlmodels/qqmltableinstancemodel.cpp
index b6836be349..1c14427b90 100644
--- a/src/qmlmodels/qqmltableinstancemodel.cpp
+++ b/src/qmlmodels/qqmltableinstancemodel.cpp
@@ -165,6 +165,9 @@ QQmlInstanceModel::ReleaseFlags QQmlTableInstanceModel::release(QObject *object,
Q_ASSERT(object);
auto modelItem = qvariant_cast<QQmlDelegateModelItem *>(object->property(kModelItemTag));
Q_ASSERT(modelItem);
+ // Ensure that the object was incubated by this QQmlTableInstanceModel
+ Q_ASSERT(m_modelItems.contains(modelItem->index));
+ Q_ASSERT(m_modelItems[modelItem->index]->object == object);
if (!modelItem->releaseObject())
return QQmlDelegateModel::Referenced;
@@ -214,6 +217,9 @@ void QQmlTableInstanceModel::dispose(QObject *object)
// The item is not referenced by anyone
Q_ASSERT(!modelItem->isObjectReferenced());
Q_ASSERT(!modelItem->isReferenced());
+ // Ensure that the object was incubated by this QQmlTableInstanceModel
+ Q_ASSERT(m_modelItems.contains(modelItem->index));
+ Q_ASSERT(m_modelItems[modelItem->index]->object == object);
m_modelItems.remove(modelItem->index);