From bfd852c5025e342af3960516df2f871aa08f5982 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 27 Mar 2025 22:17:39 +0100 Subject: [PATCH] tst_QGraphicsProxyWidget: fix memleak in forwardTouchEvent() The result of QTest::createTouchDevice() needs to be deleted by the caller. The test function didn't, so leaked the object. Fix by holding it in unique_ptr. Amends 982b70d37db337b2c57a3cfce0f24c3d00a598d6, even though the code that this patch replaced looked leaky, too. Pick-to: 6.9 6.8 6.5 5.15 Change-Id: I3c7dfab31dc6ab364195381352d98fbd9c730990 Reviewed-by: Axel Spoerl --- .../qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 28002a3232e..37ba5ea1c46 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -3816,17 +3816,17 @@ void tst_QGraphicsProxyWidget::forwardTouchEvent() EventSpy eventSpy(widget); - QPointingDevice *device = QTest::createTouchDevice(); + const std::unique_ptr device{QTest::createTouchDevice()}; QVERIFY(device); QCOMPARE(eventSpy.counts[QEvent::TouchBegin], 0); QCOMPARE(eventSpy.counts[QEvent::TouchUpdate], 0); QCOMPARE(eventSpy.counts[QEvent::TouchEnd], 0); - QTest::touchEvent(&view, device).press(0, QPoint(10, 10), &view); - QTest::touchEvent(&view, device).move(0, QPoint(15, 15), &view); - QTest::touchEvent(&view, device).move(0, QPoint(16, 16), &view); - QTest::touchEvent(&view, device).release(0, QPoint(15, 15), &view); + QTest::touchEvent(&view, device.get()).press(0, QPoint(10, 10), &view); + QTest::touchEvent(&view, device.get()).move(0, QPoint(15, 15), &view); + QTest::touchEvent(&view, device.get()).move(0, QPoint(16, 16), &view); + QTest::touchEvent(&view, device.get()).release(0, QPoint(15, 15), &view); QApplication::processEvents();