aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlmodels
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-03-09 01:00:06 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-03-09 09:58:49 +0100
commitd51d5ff3c187821929cf7b765e037423bcc90466 (patch)
tree0eed81eb1709759058ff2b3b4595ea18774a44c4 /src/qmlmodels
parenteacb1a08ee4dace7c12a6eed153b9ec69cf95966 (diff)
parent12ddd8da1b2dcfbbca10a6915547456601a726c0 (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts: src/qml/compiler/qqmlirbuilder_p.h src/qml/qml/qqmlpropertycachecreator_p.h src/qmltyperegistrar/qmltypesclassdescription.cpp src/qmltyperegistrar/qmltypesclassdescription.h src/qmltyperegistrar/qmltypescreator.cpp src/quick/items/qquicktext_p.h src/quick/util/qquickvaluetypes_p.h Change-Id: Ic209741592e7b85820bf3845722023a190ebc1c5
Diffstat (limited to 'src/qmlmodels')
-rw-r--r--src/qmlmodels/dependencies.json2
-rw-r--r--src/qmlmodels/qqmldelegatemodel.cpp10
-rw-r--r--src/qmlmodels/qqmlobjectmodel_p.h4
-rw-r--r--src/qmlmodels/qqmltableinstancemodel.cpp21
-rw-r--r--src/qmlmodels/qqmltableinstancemodel_p.h1
5 files changed, 31 insertions, 7 deletions
diff --git a/src/qmlmodels/dependencies.json b/src/qmlmodels/dependencies.json
new file mode 100644
index 0000000000..0d4f101c7a
--- /dev/null
+++ b/src/qmlmodels/dependencies.json
@@ -0,0 +1,2 @@
+[
+]
diff --git a/src/qmlmodels/qqmldelegatemodel.cpp b/src/qmlmodels/qqmldelegatemodel.cpp
index c32caafaa6..3a05bf1689 100644
--- a/src/qmlmodels/qqmldelegatemodel.cpp
+++ b/src/qmlmodels/qqmldelegatemodel.cpp
@@ -1211,11 +1211,13 @@ QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, QQ
}
Compositor::iterator it = m_compositor.find(group, index);
+ const auto flags = it->flags;
+ const auto modelIndex = it.modelIndex();
QQmlDelegateModelItem *cacheItem = it->inCache() ? m_cache.at(it.cacheIndex) : 0;
if (!cacheItem || !cacheItem->delegate) {
- QQmlComponent *delegate = resolveDelegate(it.modelIndex());
+ QQmlComponent *delegate = resolveDelegate(modelIndex);
if (!delegate)
return nullptr;
@@ -1226,17 +1228,17 @@ QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, QQ
// all related properties, and return the object (which
// has already been incubated, otherwise it wouldn't be in the pool).
addCacheItem(cacheItem, it);
- reuseItem(cacheItem, index, it->flags);
+ reuseItem(cacheItem, index, flags);
cacheItem->referenceObject();
return cacheItem->object;
}
// Since we could't find an available item in the pool, we create a new one
- cacheItem = m_adaptorModel.createItem(m_cacheMetaType, it.modelIndex());
+ cacheItem = m_adaptorModel.createItem(m_cacheMetaType, modelIndex);
if (!cacheItem)
return nullptr;
- cacheItem->groups = it->flags;
+ cacheItem->groups = flags;
addCacheItem(cacheItem, it);
}
diff --git a/src/qmlmodels/qqmlobjectmodel_p.h b/src/qmlmodels/qqmlobjectmodel_p.h
index 5b3423b480..761e9c73ec 100644
--- a/src/qmlmodels/qqmlobjectmodel_p.h
+++ b/src/qmlmodels/qqmlobjectmodel_p.h
@@ -105,8 +105,8 @@ Q_SIGNALS:
void createdItem(int index, QObject *object);
void initItem(int index, QObject *object);
void destroyingItem(QObject *object);
- void itemPooled(int index, QObject *object);
- void itemReused(int index, QObject *object);
+ Q_REVISION(2, 15) void itemPooled(int index, QObject *object);
+ Q_REVISION(2, 15) void itemReused(int index, QObject *object);
protected:
QQmlInstanceModel(QObjectPrivate &dd, QObject *parent = nullptr)
diff --git a/src/qmlmodels/qqmltableinstancemodel.cpp b/src/qmlmodels/qqmltableinstancemodel.cpp
index c1f9df3114..8c034356f3 100644
--- a/src/qmlmodels/qqmltableinstancemodel.cpp
+++ b/src/qmlmodels/qqmltableinstancemodel.cpp
@@ -150,7 +150,7 @@ QQmlDelegateModelItem *QQmlTableInstanceModel::resolveModelItem(int index)
}
// Create a new item from scratch
- modelItem = m_adaptorModel.createItem(m_metaType, index);
+ modelItem = m_adaptorModel.createItem(m_metaType.data(), index);
if (modelItem) {
modelItem->delegate = delegate;
m_modelItems.insert(index, modelItem);
@@ -243,6 +243,25 @@ void QQmlTableInstanceModel::destroyModelItem(QQmlDelegateModelItem *modelItem)
delete modelItem;
}
+void QQmlTableInstanceModel::dispose(QObject *object)
+{
+ Q_ASSERT(object);
+ auto modelItem = qvariant_cast<QQmlDelegateModelItem *>(object->property(kModelItemTag));
+ Q_ASSERT(modelItem);
+
+ modelItem->releaseObject();
+
+ // The item is not referenced by anyone
+ Q_ASSERT(!modelItem->isObjectReferenced());
+ Q_ASSERT(!modelItem->isReferenced());
+
+ m_modelItems.remove(modelItem->index);
+
+ emit destroyingItem(object);
+ delete object;
+ delete modelItem;
+}
+
void QQmlTableInstanceModel::cancel(int index)
{
auto modelItem = m_modelItems.value(index);
diff --git a/src/qmlmodels/qqmltableinstancemodel_p.h b/src/qmlmodels/qqmltableinstancemodel_p.h
index 80ba7ddaaf..57b9b26e43 100644
--- a/src/qmlmodels/qqmltableinstancemodel_p.h
+++ b/src/qmlmodels/qqmltableinstancemodel_p.h
@@ -110,6 +110,7 @@ public:
QObject *object(int index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested) override;
ReleaseFlags release(QObject *object, ReusableFlag reusable = NotReusable) override;
+ void dispose(QObject *object);
void cancel(int) override;
void drainReusableItemsPool(int maxPoolTime) override;