From 6d6ee8d6d61726f3479b3e0ffa848c34709a0e04 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 4 Apr 2025 08:35:16 +0200 Subject: [PATCH] tst_QGraphicsGridLayout: fix memleaks in setGeometry() The test function created a parent-less QGraphicsWidget, and while it added a bunch of child objects to it, that initial graphics-widgets never got an owner so it and all the children were leaked. Fix by holding it in a unique_ptr. That is the minimally-invasive fix. Amends the start of the public history. Pick-to: 6.6 6.5 5.15 Change-Id: I3ab9db721e1343f2bd8d9fdd0ee6e86733a66da2 Reviewed-by: Axel Spoerl (cherry picked from commit 2e0988190febe65b6d12b7956bd22b04843e2e6d) Reviewed-by: Qt Cherry-pick Bot --- .../qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index 0a02665dfcd..134ffbea3ff 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -1498,7 +1498,7 @@ void tst_QGraphicsGridLayout::setGeometry() { QFETCH(QRectF, rect); - QGraphicsWidget *window = new QGraphicsWidget; + const auto window = std::make_unique(); QGraphicsGridLayout *layout = new QGraphicsGridLayout(); window->setLayout(layout); QGraphicsGridLayout *layout2 = new QGraphicsGridLayout();