aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlmodels
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-03-20 11:30:31 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-03-23 09:58:34 +0100
commit29fc018b74de3869941438c1f51b3202f93e5198 (patch)
treefb5e53d03db1c6c66875e9298e38bf09a45c060e /src/qmlmodels
parent34a5567ae6a109c7a0ce1cf65e5e1a6d8786881e (diff)
QQmlDelegateModel: On deletion, cancel any remaining incubations
This fixes the memory leaks from the "x items in the process of being created at engine destruction" situation. Change-Id: I65fe278ead3d4de0cbddc075972a6774b231814f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qmlmodels')
-rw-r--r--src/qmlmodels/qqmldelegatemodel.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/qmlmodels/qqmldelegatemodel.cpp b/src/qmlmodels/qqmldelegatemodel.cpp
index 095b66b379..a68631830d 100644
--- a/src/qmlmodels/qqmldelegatemodel.cpp
+++ b/src/qmlmodels/qqmldelegatemodel.cpp
@@ -269,13 +269,23 @@ QQmlDelegateModel::~QQmlDelegateModel()
Q_ASSERT(cacheItem->contextData->refCount == 1);
cacheItem->contextData = nullptr;
cacheItem->scriptRef -= 1;
+ } else if (cacheItem->incubationTask) {
+ // Both the incubationTask and the object may hold a scriptRef,
+ // but if both are present, only one scriptRef is held in total.
+ cacheItem->scriptRef -= 1;
}
+
cacheItem->groups &= ~Compositor::UnresolvedFlag;
cacheItem->objectRef = 0;
+
+ if (cacheItem->incubationTask) {
+ d->releaseIncubator(cacheItem->incubationTask);
+ cacheItem->incubationTask->vdm = nullptr;
+ cacheItem->incubationTask = nullptr;
+ }
+
if (!cacheItem->isReferenced())
delete cacheItem;
- else if (cacheItem->incubationTask)
- cacheItem->incubationTask->vdm = nullptr;
}
}