From 7bf07cc12c4a6a44dfabb10c34b6df9dc8ff4a33 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 28 Mar 2025 09:47:24 +0100 Subject: [PATCH] tst_QGraphicsWidget: fix memleak in qgraphicswidget() The QGraphicsWidget `parent` didn't have a parent itself, and the test function neglected to delete the object manually, leaking it. To fix, allocate it on the stack. Amends the start of the public history. Pick-to: 6.8 6.5 5.15 Change-Id: Ie9814655c1a52b6dc0d15076eca591fe710d51ae Reviewed-by: Axel Spoerl (cherry picked from commit 76e76afb83b87664aeeaf61b400e4259ce80f49a) Reviewed-by: Qt Cherry-pick Bot --- .../graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp index e6d6ed9f82d..2a71e28f2f3 100644 --- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp @@ -289,8 +289,8 @@ void tst_QGraphicsWidget::qgraphicswidget() QCOMPARE(widget.call_propertyChange(QString(), QVariant()), QVariant()); widget.call_sizeHint(Qt::PreferredSize, QSizeF()); - QGraphicsWidget *parent = new QGraphicsWidget; - SizeHinter *child = new SizeHinter(parent); + QGraphicsWidget parent; + SizeHinter *child = new SizeHinter(&parent); QCOMPARE(child->minimumSize(), QSizeF(5, 5)); }