From f3a02fe39d8d0bfea8fa0f087bb95c6e65d77b45 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 27 Mar 2025 13:02:35 +0100 Subject: [PATCH] tst_QGraphicsLayout: fix memleaks in alternativeLayoutItems() I honestly didn't bother to figure out the ownership relationships between these items; the QGraphicsView docs don't help much: > The layout takes ownership of the items. In some cases when the > layout item also inherits from QGraphicsItem (such as > QGraphicsWidget) there will be a ambiguity in ownership because the > layout item belongs to two ownership hierarchies but asan said that the AnimatedLayoutItem objects were leaked, so hold them in unique_ptrs now. Amends the start of the public history. Pick-to: 6.9 6.8 6.5 5.15 Change-Id: Icd0eabc4129b57251bbec7f8e3752f99ee584cf3 Reviewed-by: Axel Spoerl --- .../qgraphicslayout/tst_qgraphicslayout.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp index 17db8f240c2..40339f0f50d 100644 --- a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp @@ -708,16 +708,16 @@ void tst_QGraphicsLayout::alternativeLayoutItems() lout->setSpacing(0); QGraphicsRectItem *item1 = new QGraphicsRectItem; - AnimatedLayoutItem *li1 = new AnimatedLayoutItem(item1); - lout->addItem(li1); + const auto li1 = std::make_unique(item1); + lout->addItem(li1.get()); QGraphicsRectItem *item2 = new QGraphicsRectItem; - AnimatedLayoutItem *li2 = new AnimatedLayoutItem(item2); - lout->addItem(li2); + const auto li2 = std::make_unique(item2); + lout->addItem(li2.get()); QGraphicsRectItem *item3 = new QGraphicsRectItem; - AnimatedLayoutItem *li3 = new AnimatedLayoutItem(item3); - lout->addItem(li3); + const auto li3 = std::make_unique(item3); + lout->addItem(li3.get()); window->setLayout(lout);