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 <Friedemann.Kleint@qt.io>
This commit is contained in:
Marc Mutz 2016-09-26 21:37:49 +02:00
parent 77eafa8d89
commit b827b8ccf7

View File

@ -353,6 +353,8 @@ void tst_QGridLayout::setMinAndMaxSize()
layout.removeItem(spacer); layout.removeItem(spacer);
delete spacer;
spacer = Q_NULLPTR;
rightChild.hide(); rightChild.hide();
QApplication::sendPostedEvents(0, 0); QApplication::sendPostedEvents(0, 0);
@ -1601,10 +1603,10 @@ void tst_QGridLayout::contentsRect()
void tst_QGridLayout::distributeMultiCell() void tst_QGridLayout::distributeMultiCell()
{ {
QWidget w; QWidget w;
Qt42Style *style = new Qt42Style(); Qt42Style style;
style->spacing = 9; style.spacing = 9;
w.setStyle(style); w.setStyle(&style);
QGridLayout grid; QGridLayout grid;
w.setLayout(&grid); w.setLayout(&grid);