tst_QGraphicsGridLayout: fix memleaks in setGeometry()

The test function created a parent-less QGraphicsWidget, and while it
added a bunch of child objects to it, that initial graphics-widgets
never got an owner so it and all the children were leaked.

Fix by holding it in a unique_ptr. That is the minimally-invasive fix.

Amends the start of the public history.

Pick-to: 6.9 6.6 6.5 5.15
Change-Id: I3ab9db721e1343f2bd8d9fdd0ee6e86733a66da2
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
Marc Mutz 2025-04-04 08:35:16 +02:00
parent d21434d187
commit 2e0988190f

View File

@ -1498,7 +1498,7 @@ void tst_QGraphicsGridLayout::setGeometry()
{ {
QFETCH(QRectF, rect); QFETCH(QRectF, rect);
QGraphicsWidget *window = new QGraphicsWidget; const auto window = std::make_unique<QGraphicsWidget>();
QGraphicsGridLayout *layout = new QGraphicsGridLayout(); QGraphicsGridLayout *layout = new QGraphicsGridLayout();
window->setLayout(layout); window->setLayout(layout);
QGraphicsGridLayout *layout2 = new QGraphicsGridLayout(); QGraphicsGridLayout *layout2 = new QGraphicsGridLayout();