tst_QGraphicsGridLayout: fix memleak in spanAcrossEmptyRow()
The test function created a parent-less QGraphicsWidget on the heap, and didn't otherwise transfer ownership of it to another object, so the object was leaked. The minimal fix is to hold the graphics-widget in a unique_ptr. This requires to change the following line, too (as would the alternative, allocation on the stack), but the rest of the function can stay as-is (unlike with stack allocation, which would require further s/[.]/->/. Amends 4f072e2d3d7e429359ff15a615d02712bff7ee51. Pick-to: 6.9 6.8 6.5 5.15 Change-Id: Ide305dde7934747dbc3acdb49f5a75e98563828c Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
parent
4d0f979610
commit
45f317fba0
@ -3311,8 +3311,8 @@ void tst_QGraphicsGridLayout::spanningItem()
|
|||||||
|
|
||||||
void tst_QGraphicsGridLayout::spanAcrossEmptyRow()
|
void tst_QGraphicsGridLayout::spanAcrossEmptyRow()
|
||||||
{
|
{
|
||||||
QGraphicsWidget *form = new QGraphicsWidget(0, Qt::Window);
|
const auto form = std::make_unique<QGraphicsWidget>(nullptr, Qt::Window);
|
||||||
QGraphicsGridLayout *layout = new QGraphicsGridLayout(form);
|
QGraphicsGridLayout *layout = new QGraphicsGridLayout(form.get());
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
layout->setSpacing(0);
|
layout->setSpacing(0);
|
||||||
RectWidget *w1 = new RectWidget;
|
RectWidget *w1 = new RectWidget;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user