diff options
author | Jan Arve Saether <jan-arve.saether@qt.io> | 2017-01-05 13:42:14 +0100 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@qt.io> | 2017-01-12 09:56:40 +0000 |
commit | 342c72da64cac4aec1463091f6fe0bfb16cd1850 (patch) | |
tree | d0e77f8fcb067fa51f4eb7667b3657d09ff4af54 /tests/auto/quick/qquicklayouts | |
parent | 6746db54f2adb40b836ce41101462bc38604749f (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 'tests/auto/quick/qquicklayouts')
-rw-r--r-- | tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml index 2d4e227a9e..97860458fe 100644 --- a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml +++ b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml @@ -802,6 +802,27 @@ Item { layout.destroy() // Do not crash } + Component { + id: rectangle_Component + Rectangle { + width: 100 + height: 50 + } + } + + function test_destroyImplicitInvisibleLayout() + { + var root = rectangle_Component.createObject(container) + root.visible = false + var layout = layout_deleteLayout.createObject(root) + layout.visible = true + // at this point the layout is still invisible because root is invisible + layout.destroy() + // Do not crash when destructing the layout + waitForRendering(container) // should ideally call gc(), but does not work + root.destroy() + } + function test_sizeHintWithHiddenChildren(data) { var layout = layout_sizeHint_Component.createObject(container) var grid = layout.children[0] |