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:
parent
77eafa8d89
commit
b827b8ccf7
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user