aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlmodels/qqmllistmodel.cpp
diff options
context:
space:
mode:
authorCathy Park <cathy.park@lge.com>2021-08-19 15:40:27 +0900
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-08-26 09:33:04 +0000
commitb1f7d1380cef500dba25586c0b6e95550e986343 (patch)
treea71bbc2c70061e2480f0810071047dd1c1328031 /src/qmlmodels/qqmllistmodel.cpp
parent5ae4f2a1dceda33e0d732fcca5d5f0ed15758eb5 (diff)
qqmllistmodel: Fix QObjects setting indestructible
It makes a QObject indestructable only if its ownership is determined. This fixes an issue where a QObject created by createObject() in QML becomes indestructable once it is appended to a ListModel. Fixes: QTBUG-95895 Change-Id: I30647298977d7901dab938626e8f94b9910c21e3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Jaeyoon Jung <jaeyoon.jung@lge.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> (cherry picked from commit 69e07c55ad9b49b7643ffddfedc9a558983272ad) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/qmlmodels/qqmllistmodel.cpp')
-rw-r--r--src/qmlmodels/qqmllistmodel.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/qmlmodels/qqmllistmodel.cpp b/src/qmlmodels/qqmllistmodel.cpp
index a9c58d59a5..b71931cc85 100644
--- a/src/qmlmodels/qqmllistmodel.cpp
+++ b/src/qmlmodels/qqmllistmodel.cpp
@@ -1112,7 +1112,7 @@ static void setQObjectOwnership(char *mem, QObject *o)
if (!ddata)
ddata = QQmlData::get(o, true);
- ddata->indestructible = true;
+ ddata->indestructible = ownership != 0;
ddata->explicitIndestructibleSet = false;
new (mem) ListElement::GuardedQObjectPointer(