tst_QGraphicsGridLayout: fix memleaks in columnSpacing()
The populateLayout() function adds parent-less QGraphicsWidgets (RectWidgets) to the layout. If the layout had a graphics-widget parent, it would reparent them onto the parent. But it didn't, so it didn't. Therefore, the 2nd and 3rd part of the test function (as denoted by the top-level scopes in the function) leaked a lot of items. The first part of the function already used a widget, itself without parent, but added to a QGraphicsScene allocated on the stack, so was not leaking. To fix, give the layouts a graphics-widget parent. Then the layout doesn't need to be deleted anymore, either. Amends the start of the public history. Pick-to: 6.9 6.8 6.5 5.15 Change-Id: I7e63c51cf037818fb1e519dab5394ad75c74d67d Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
parent
0840c4f1ab
commit
5a559758d1
@ -867,6 +867,8 @@ void tst_QGraphicsGridLayout::columnSpacing()
|
||||
// don't include items and spacings that was previously part of the layout
|
||||
// (horizontal)
|
||||
QGraphicsGridLayout *layout = new QGraphicsGridLayout;
|
||||
QGraphicsWidget parent;
|
||||
parent.setLayout(layout);
|
||||
populateLayout(layout, 3, 1);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setSpacing(0);
|
||||
@ -879,12 +881,13 @@ void tst_QGraphicsGridLayout::columnSpacing()
|
||||
QCOMPARE(layout->preferredSize(), QSizeF(60, 25));
|
||||
layout->removeAt(1);
|
||||
QCOMPARE(layout->preferredSize(), QSizeF(25, 25));
|
||||
delete layout;
|
||||
}
|
||||
{
|
||||
// don't include items and spacings that was previously part of the layout
|
||||
// (vertical)
|
||||
QGraphicsGridLayout *layout = new QGraphicsGridLayout;
|
||||
QGraphicsWidget parent;
|
||||
parent.setLayout(layout);
|
||||
populateLayout(layout, 2, 2);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setSpacing(0);
|
||||
@ -899,7 +902,6 @@ void tst_QGraphicsGridLayout::columnSpacing()
|
||||
QCOMPARE(layout->preferredSize(), QSizeF(60, 25));
|
||||
layout->removeAt(1);
|
||||
QCOMPARE(layout->preferredSize(), QSizeF(25, 25));
|
||||
delete layout;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user