From b827b8ccf7311d8bc3551501a5faa6d456da052b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 26 Sep 2016 21:37:49 +0200 Subject: Plug memleaks in tst_QGridLayout In setMinAndMaxSize(), QLayout::removeItem() doesn't actually delete the removed item. We have to do that ourselves (RAII not necessary, since the spacer is owned by the layout until we remove it). In distributeMultiCell(), allocate the QStyle subclass on the stack so the compiler cleans it up properly on all exit paths (was: unconditional leak). Change-Id: I24f8f11af2bfc5abf78f9aab0139dcfe0187402b Reviewed-by: Friedemann Kleint --- tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp index 1e67c675ef..255481031b 100644 --- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp +++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp @@ -353,6 +353,8 @@ void tst_QGridLayout::setMinAndMaxSize() layout.removeItem(spacer); + delete spacer; + spacer = Q_NULLPTR; rightChild.hide(); QApplication::sendPostedEvents(0, 0); @@ -1601,10 +1603,10 @@ void tst_QGridLayout::contentsRect() void tst_QGridLayout::distributeMultiCell() { QWidget w; - Qt42Style *style = new Qt42Style(); - style->spacing = 9; + Qt42Style style; + style.spacing = 9; - w.setStyle(style); + w.setStyle(&style); QGridLayout grid; w.setLayout(&grid); -- cgit v1.2.3