From 9bab38b1330a4106e920b66538e4e14b795d33e2 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 27 Mar 2025 13:10:27 +0100 Subject: [PATCH] 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 --- .../qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index 65212e94cc2..f85c3fcc821 100644 --- a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -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);