tst_QGraphicsItem: fix leak of m_touchDevice
The result of QTest::createTouchScreen() needs to be deleted by the caller, and this test didn't do that. To fix, put the object into a unique_ptr. Amends 982b70d37db337b2c57a3cfce0f24c3d00a598d6, though the code it replaced seems to have had the same problem. Pick-to: 6.8 6.5 5.15 Change-Id: I361a0b37b717ac543b003fb48a4a6934b6d79a03 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit e9a7c4a224a5859fb954b149ea0a0d3b0e4ada13) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
96aa7232c7
commit
5b4e57778a
@ -469,7 +469,7 @@ private slots:
|
||||
|
||||
private:
|
||||
GraphicsItems paintedItems;
|
||||
QPointingDevice *m_touchDevice = QTest::createTouchDevice();
|
||||
std::unique_ptr<QPointingDevice> m_touchDevice{QTest::createTouchDevice()};
|
||||
};
|
||||
|
||||
void tst_QGraphicsItem::cleanup()
|
||||
@ -11077,13 +11077,14 @@ void tst_QGraphicsItem::touchEventPropagation()
|
||||
view.setSceneRect(touchEventReceiver->boundingRect());
|
||||
view.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&view));
|
||||
QInputDevicePrivate::get(m_touchDevice)->setAvailableVirtualGeometry(view.screen()->geometry());
|
||||
QInputDevicePrivate::get(m_touchDevice.get())
|
||||
->setAvailableVirtualGeometry(view.screen()->geometry());
|
||||
|
||||
QCOMPARE(touchEventReceiver->touchBeginEventCount(), 0);
|
||||
|
||||
const QPointF scenePos = view.sceneRect().center();
|
||||
sendMousePress(&scene, scenePos);
|
||||
QMutableTouchEvent touchBegin(QEvent::TouchBegin, m_touchDevice, Qt::NoModifier,
|
||||
QMutableTouchEvent touchBegin(QEvent::TouchBegin, m_touchDevice.get(), Qt::NoModifier,
|
||||
createTouchPoints(view, scenePos, QSizeF(10, 10)));
|
||||
touchBegin.setTarget(view.viewport());
|
||||
|
||||
@ -11137,11 +11138,12 @@ void tst_QGraphicsItem::touchEventTransformation()
|
||||
view.setTransform(viewTransform);
|
||||
view.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&view));
|
||||
QInputDevicePrivate::get(m_touchDevice)->setAvailableVirtualGeometry(view.screen()->geometry());
|
||||
QInputDevicePrivate::get(m_touchDevice.get())
|
||||
->setAvailableVirtualGeometry(view.screen()->geometry());
|
||||
|
||||
QCOMPARE(touchEventReceiver->touchBeginEventCount(), 0);
|
||||
|
||||
QMutableTouchEvent touchBegin(QEvent::TouchBegin, m_touchDevice, Qt::NoModifier,
|
||||
QMutableTouchEvent touchBegin(QEvent::TouchBegin, m_touchDevice.get(), Qt::NoModifier,
|
||||
createTouchPoints(view, touchScenePos, ellipseDiameters));
|
||||
touchBegin.setTarget(view.viewport());
|
||||
QCoreApplication::sendEvent(&scene, &touchBegin);
|
||||
@ -11155,7 +11157,7 @@ void tst_QGraphicsItem::touchEventTransformation()
|
||||
COMPARE_POINTF(touchBeginPoint.position(), expectedItemPos);
|
||||
COMPARE_SIZEF(touchBeginPoint.ellipseDiameters(), ellipseDiameters); // Must remain untransformed
|
||||
|
||||
QMutableTouchEvent touchUpdate(QEvent::TouchUpdate, m_touchDevice, Qt::NoModifier,
|
||||
QMutableTouchEvent touchUpdate(QEvent::TouchUpdate, m_touchDevice.get(), Qt::NoModifier,
|
||||
createTouchPoints(view, touchScenePos, ellipseDiameters, QEventPoint::State::Updated));
|
||||
touchUpdate.setTarget(view.viewport());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user