tst_QGraphicsEffectSource: fix memleak in pixmapPadding()

The test function didn't delete the heap-allocated QGraphicsScene,
because, a comment indicated, there was some "corruption in scene
destruction".

Fix the memleak by creating the scene object on the stack. A local
asan+ubsan build is clean, and so is a valgrind run, so whatever it
was, it seems fixed by now.

Amends the start of the public history.

Picking back to verify that it's been, indeed, fixed in all active
branches.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ic7f96c7195d58ccbff45b17f76fb2babd1c1b648
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Marc Mutz 2025-03-24 16:11:07 +01:00
parent d8b79dc1c9
commit 4293381545

View File

@ -351,10 +351,10 @@ void tst_QGraphicsEffectSource::pixmapPadding()
QPixmap pm(10, 10);
pm.fill(Qt::red);
QGraphicsScene *scene = new QGraphicsScene();
PaddingEffect *effect = new PaddingEffect(scene);
QGraphicsScene scene;
PaddingEffect *effect = new PaddingEffect(&scene);
QGraphicsPixmapItem *pmItem = new QGraphicsPixmapItem(pm);
scene->addItem(pmItem);
scene.addItem(pmItem);
pmItem->setGraphicsEffect(effect);
QFETCH(int, coordinateMode);
@ -366,14 +366,11 @@ void tst_QGraphicsEffectSource::pixmapPadding()
effect->padMode = (QGraphicsEffect::PixmapPadMode) padMode;
effect->coordinateMode = (Qt::CoordinateSystem) coordinateMode;
scene->render(&dummyPainter, scene->itemsBoundingRect(), scene->itemsBoundingRect());
scene.render(&dummyPainter, scene.itemsBoundingRect(), scene.itemsBoundingRect());
QCOMPARE(effect->pix.size(), size);
QCOMPARE(effect->offset, offset);
QCOMPARE(effect->pix.toImage().pixel(0, 0), ulPixel);
// ### Fix corruption in scene destruction, then enable...
// delete scene;
}
QTEST_MAIN(tst_QGraphicsEffectSource)