aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/layouts/qquicklinearlayout.cpp
diff options
context:
space:
mode:
authorJan Arve Saether <jan-arve.saether@qt.io>2017-01-05 13:42:14 +0100
committerJan Arve Sæther <jan-arve.saether@qt.io>2017-01-12 09:56:40 +0000
commit342c72da64cac4aec1463091f6fe0bfb16cd1850 (patch)
treed0e77f8fcb067fa51f4eb7667b3657d09ff4af54 /src/imports/layouts/qquicklinearlayout.cpp
parent6746db54f2adb40b836ce41101462bc38604749f (diff)
Avoid needless notifications when destroying layouts
When deleting a layout with children, it ends up in ~QQuickItem(), which in turn will call setParentItem(0). setParentItem(0) will in turn call setEffectiveVisibleRecur(), which will recurse down all its descendants. Therefore, deleting a top level layout might trigger item change listeners for *all* its descendants, not only its direct children. This behavior might even cause crashes: The visibility changes will then trigger an invalidation of the layout, which will propagate up the parent hierarchy, and potentially call invalidate() on a partially-destroyed layout, which then might crash. Change-Id: I48e11d57f69e9011ced6c3a0b51e3d89b24ad5c1 Task-number: QTBUG-55103 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/imports/layouts/qquicklinearlayout.cpp')
-rw-r--r--src/imports/layouts/qquicklinearlayout.cpp6
1 files changed, 1 insertions, 5 deletions
diff --git a/src/imports/layouts/qquicklinearlayout.cpp b/src/imports/layouts/qquicklinearlayout.cpp
index 13fdd496c2..50b3eed87e 100644
--- a/src/imports/layouts/qquicklinearlayout.cpp
+++ b/src/imports/layouts/qquicklinearlayout.cpp
@@ -305,11 +305,7 @@ QQuickGridLayoutBase::~QQuickGridLayoutBase()
// Remove item listeners so we do not act on signalling unnecessarily
// (there is no point, as the layout will be torn down anyway).
- for (int i = 0; i < itemCount(); ++i) {
- QQuickItem *item = itemAt(i);
- QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::SiblingOrder | QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight | QQuickItemPrivate::Destroyed | QQuickItemPrivate::Visibility);
- }
-
+ deactivateRecur();
delete d->styleInfo;
}