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 <Friedemann.Kleint@qt.io>
bb10
Marc Mutz 2016-09-26 21:37:49 +02:00
parent fcf4767bff
commit 77eafa8d89
1 changed files with 2 additions and 2 deletions

View File

@ -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);