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.8 6.5 5.15
Change-Id: I5c7356ac93c04d648eb31888105b480791fbe155
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit b518a385ad03c3b199f4704088d688b9bf1f3cc6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2025-04-02 21:27:54 +02:00 committed by Qt Cherry-pick Bot
parent adbbd47314
commit a6f082df9b

View File

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