diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-04-05 19:07:05 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-04-10 10:52:20 +0000 |
commit | 3941af88662cdf8bad478813233986e695fa4dcc (patch) | |
tree | 4a755e874f399f4a4400e6c4bd49699872db5294 | |
parent | f0eed56490080a6769645f184bb6f13dfe7d23e3 (diff) |
Cancel incubation recursively
It turns out that cancelling the incubation of eg. a combobox popup
alone is not enough when its children might be incubating and would
be left incorrectly guarded. Cancel recursively the whole object
tree of a replaced/destroyed delegate to avoid that.
Task-number: QTBUG-50992
Change-Id: Ia06931c4c7af3ed8bb56af6c29eb51081c4fccbb
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
-rw-r--r-- | src/quicktemplates2/qquickcontrol.cpp | 18 |
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; } |