diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp index bf957fce109..9478eb50bcc 100644 --- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp @@ -1356,9 +1356,12 @@ void tst_QGraphicsWidget::setStyle() int oldEventCounts = widget.eventCount; + std::unique_ptr reaper; + QFETCH(QString, style); if (!style.isEmpty()) { QStyle *fstyle = QStyleFactory::create(style); + reaper.reset(fstyle); widget.setStyle(fstyle); QCOMPARE(widget.style(), fstyle); } else {