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.8 6.5 5.15
Change-Id: Ic7f96c7195d58ccbff45b17f76fb2babd1c1b648
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit 429338154540f92a3efdbe8813a41f98dddeaa08)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2025-03-24 16:11:07 +01:00 committed by Qt Cherry-pick Bot
parent eba728f1a3
commit 3b8a5859f8

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)