tst_QGraphicsLinearLayout: remove remaining memleaks in insertItem()
After the QGraphicsWidgets have been dealt with in a previous commit, the last leak in the function is that of 'item'. Fix by holding it in a unique_ptr. Amends the start of the public history. Pick-to: 6.9 6.8 6.5 5.15 Change-Id: I56986139a2b7865cf367bdd25ccde90d5e1c50ca Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
parent
8914732708
commit
59b18d07e7
@ -468,18 +468,18 @@ void tst_QGraphicsLinearLayout::insertItem()
|
|||||||
for (int i = 0; i < layoutCount; ++i)
|
for (int i = 0; i < layoutCount; ++i)
|
||||||
layout.addItem(new SubQGraphicsLinearLayout);
|
layout.addItem(new SubQGraphicsLinearLayout);
|
||||||
|
|
||||||
QGraphicsLayoutItem *item = nullptr;
|
std::unique_ptr<QGraphicsLayoutItem> item = nullptr;
|
||||||
if (isWidget)
|
if (isWidget)
|
||||||
item = new QGraphicsWidget;
|
item = std::make_unique<QGraphicsWidget>();
|
||||||
else
|
else
|
||||||
item = new SubQGraphicsLinearLayout;
|
item = std::make_unique<SubQGraphicsLinearLayout>();
|
||||||
|
|
||||||
QSizeF oldSizeHint = layout.sizeHint(Qt::PreferredSize, QSizeF());
|
QSizeF oldSizeHint = layout.sizeHint(Qt::PreferredSize, QSizeF());
|
||||||
layout.insertItem(insertItemAt, item);
|
layout.insertItem(insertItemAt, item.get());
|
||||||
QCOMPARE(layout.count(), itemCount + layoutCount + 1);
|
QCOMPARE(layout.count(), itemCount + layoutCount + 1);
|
||||||
|
|
||||||
if (insertItemAt >= 0 && (itemCount + layoutCount >= 0)) {
|
if (insertItemAt >= 0 && (itemCount + layoutCount >= 0)) {
|
||||||
QCOMPARE(layout.itemAt(insertItemAt), item);
|
QCOMPARE(layout.itemAt(insertItemAt), item.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
layout.activate();
|
layout.activate();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user