summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@qinetic.com.au>2016-09-09 14:52:05 +1000
committerMartin Jones <martin.jones@qinetic.com.au>2016-09-15 00:00:20 +0000
commit2a7bfd6b37552b5812fa0e18f0212121d6c1703a (patch)
tree311e6f74c00b0c429e97c54c885c90a3724c8b0b /src
parent82176ad2090b236e3255a8b4ae26557e4bc932c0 (diff)
Destroy an incubating delegate if it is removed before incubation completes
Removing an item from a model after its delegate has started incubation, but before it has completed results is an orphaned item. Task-number: QTBUG-55901 Change-Id: I3d3136dc05a950ca38d53687ae7d38a6d0c7ec35 Reviewed-by: Andrew den Exter <andrew.den.exter@qinetic.com.au>
Diffstat (limited to 'src')
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index f2de911725..21f89cd4ec 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -1310,9 +1310,23 @@ void QQmlDelegateModelPrivate::itemsRemoved(
}
} else {
if (QQDMIncubationTask *incubationTask = cacheItem->incubationTask) {
- for (int i = 1; i < m_groupCount; ++i) {
- if (remove.inGroup(i))
- incubationTask->index[i] = remove.index[i];
+ if (!cacheItem->isObjectReferenced()) {
+ releaseIncubator(cacheItem->incubationTask);
+ cacheItem->incubationTask = 0;
+ if (cacheItem->object) {
+ QObject *object = cacheItem->object;
+ cacheItem->destroyObject();
+ if (QQuickPackage *package = qmlobject_cast<QQuickPackage *>(object))
+ emitDestroyingPackage(package);
+ else
+ emitDestroyingItem(object);
+ }
+ cacheItem->scriptRef -= 1;
+ } else {
+ for (int i = 1; i < m_groupCount; ++i) {
+ if (remove.inGroup(i))
+ incubationTask->index[i] = remove.index[i];
+ }
}
}
if (QQmlDelegateModelAttached *attached = cacheItem->attached) {