tst_QGraphicsGridLayout: fix memory leaks in columnCount()
The populateLayout() function adds parent-less QGraphicsWidgets (RectItems) to the layout. If the layout had a graphics-widget parent, it would reparent the items added to it onto the parent. But it didn't, so it didn't. Therefore, the last part of the test function (as denoted by the re-creation of `layout`) leaked a lot of items, including `layout`. To fix, give the layout the existing graphics-widget parent. Then the layout itself isn't leaked anymore, either. Amends the start of the public history. Essentially the same commit for columnCount() that b9836518a367a31a48027a5bf81c4973b847b442 was for rowCount(). Pick-to: 6.9 6.8 6.5 5.15 Change-Id: Ic38dfccfa41049d96eb0cf5811271ac17f2b1f91 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
parent
fe0b29a45c
commit
d21434d187
@ -606,6 +606,7 @@ void tst_QGraphicsGridLayout::columnCount()
|
||||
// ### Talk with Jasmin. Not sure if removeAt() should adjust columnCount().
|
||||
widget->setLayout(0);
|
||||
layout = new QGraphicsGridLayout();
|
||||
widget->setLayout(layout);
|
||||
populateLayout(layout, 3, 2, hasHeightForWidth);
|
||||
QCOMPARE(layout->columnCount(), 3);
|
||||
layout->removeAt(5);
|
||||
|
Loading…
x
Reference in New Issue
Block a user