tst_QGraphicsLinearLayout: fix memleak in testStretch()

QGraphicsView, being a QWidget, needs to have a parent or be manually
deleted. The test function did neither, so leaked the view.

Fix by allocating it on the stack.

Amends 913ff732004c2c61c39bcdd82ff05ea1827f328b.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: If012d4b833849285b62e2a4b4089457c2aef1d88
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
Marc Mutz 2025-03-27 13:10:27 +01:00
parent f3a02fe39d
commit 9bab38b133

View File

@ -1165,8 +1165,7 @@ void tst_QGraphicsLinearLayout::setStretchFactor()
void tst_QGraphicsLinearLayout::testStretch()
{
QGraphicsScene scene;
QGraphicsView *view = new QGraphicsView(&scene);
Q_UNUSED(view);
QGraphicsView view(&scene);
QGraphicsWidget *form = new QGraphicsWidget(0, Qt::Window);
scene.addItem(form);