aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/quicktemplates2/qquickcontrol.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp
index b673a424..eb66f313 100644
--- a/src/quicktemplates2/qquickcontrol.cpp
+++ b/src/quicktemplates2/qquickcontrol.cpp
@@ -866,12 +866,24 @@ QLocale QQuickControlPrivate::calcLocale(const QQuickItem *item)
}
/*
- Cancels incubation to avoid "Object destroyed during incubation" (QTBUG-50992)
+ Cancels incubation recursively to avoid "Object destroyed during incubation" (QTBUG-50992)
*/
+static void cancelIncubation(QObject *object, QQmlContext *context)
+{
+ const auto children = object->children();
+ for (QObject *child : children)
+ cancelIncubation(child, context);
+ QQmlIncubatorPrivate::cancel(object, context);
+}
+
void QQuickControlPrivate::destroyDelegate(QObject *delegate, QObject *parent)
{
- if (delegate && parent)
- QQmlIncubatorPrivate::cancel(delegate, qmlContext(parent));
+ if (!delegate)
+ return;
+
+ QQmlContext *context = parent ? qmlContext(parent) : nullptr;
+ if (context)
+ cancelIncubation(delegate, context);
delete delegate;
}