tst_QGraphicsGridLayout: fix memleaks in addItem()

Both `layout` and `wid` were created without parents, and not otherwise added to
objects that would take their ownership; only `layout` was explicitly deleted
at the end of the function, `wid` was leaked.

The usual solution, giving them a stack-allocated graphics-widget as
parent that will delete them, doesn't work here, because the layout
does refuse to add the widget in some test rows.

Since there are no checks in-between the allocation and de-allocation
(this test is only checking for expected warning messages), do the
minimal fix and explicitly delete `wid`, as it was already done for
`layout`.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I5c7356ac93c04d648eb31888105b480791fbe155
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
Marc Mutz 2025-04-02 21:27:54 +02:00
parent fc89096bcb
commit b518a385ad

View File

@ -419,6 +419,7 @@ void tst_QGraphicsGridLayout::addItem()
}
layout->addItem(wid, row, column, rowSpan, columnSpan, alignment);
delete wid;
delete layout;
}