From 77eafa8d890bc80813159ad29ba3a4e1909866fd Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 26 Sep 2016 21:37:49 +0200 Subject: Plug memleaks in tst_QBoxLayout In sizeConstraints(), QLayout::takeAt(), as the name suggests, doesn't actually delete the item. We have to do that ourselves. Likewise, in replaceWidget(), QLayout::replaceWidget() also doesn't delete the affected item, but returns it. That's spectacularly bad API design, but the leak is easy to fix: just delete the return value. Change-Id: I8dcbc59898949eabce766cda2c0edae2e1f2799e Reviewed-by: Friedemann Kleint --- tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/auto/widgets/kernel/qboxlayout') diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp index aeaf1e7bf0..ed5b763b0f 100644 --- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp +++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp @@ -188,7 +188,7 @@ void tst_QBoxLayout::sizeConstraints() window.show(); QTest::qWaitForWindowExposed(&window); QSize sh = window.sizeHint(); - lay->takeAt(1); + delete lay->takeAt(1); QVERIFY(sh.width() >= window.sizeHint().width() && sh.height() >= window.sizeHint().height()); @@ -517,7 +517,7 @@ void tst_QBoxLayout::replaceWidget() QCOMPARE(boxLayout->indexOf(replaceFrom), 1); QCOMPARE(boxLayout->indexOf(replaceTo), -1); - boxLayout->replaceWidget(replaceFrom, replaceTo); + delete boxLayout->replaceWidget(replaceFrom, replaceTo); QCOMPARE(boxLayout->indexOf(replaceFrom), -1); QCOMPARE(boxLayout->indexOf(replaceTo), 1); -- cgit v1.2.3