tst_QGestureRecognizer: do not leak the point device
QTest::createTouchDevice() passes ownership of the device to the caller, so make sure to delete it. Change-Id: I100d3de9eab8ec9f88ed3e0850ada9d988bd962e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 28d0e658e297b5de52fb0cccaede08179c7f4b8c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 8ef6d4ede857691798465eafcb7571f6c42c0ba9)
This commit is contained in:
parent
6be8e06784
commit
d25dbb9a7b
@ -12,6 +12,7 @@
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QDebug>
|
||||
#include <memory>
|
||||
|
||||
class tst_QGestureRecognizer : public QObject
|
||||
{
|
||||
@ -33,7 +34,7 @@ private Q_SLOTS:
|
||||
|
||||
private:
|
||||
const int m_fingerDistance;
|
||||
QPointingDevice *m_touchDevice;
|
||||
std::unique_ptr<QPointingDevice> m_touchDevice;
|
||||
};
|
||||
|
||||
tst_QGestureRecognizer::tst_QGestureRecognizer()
|
||||
@ -164,7 +165,7 @@ void tst_QGestureRecognizer::panGesture()
|
||||
for (int i = 0; i < panPoints; ++i)
|
||||
points.append(QPoint(10 + i *20, 10 + i *20));
|
||||
|
||||
QTest::QTouchEventWidgetSequence panSequence = QTest::touchEvent(&widget, m_touchDevice);
|
||||
QTest::QTouchEventWidgetSequence panSequence = QTest::touchEvent(&widget, m_touchDevice.get());
|
||||
pressSequence(panSequence, points, &widget);
|
||||
linearSequence(5, QPoint(20, 20), panSequence, points, &widget);
|
||||
releaseSequence(panSequence, points, &widget);
|
||||
@ -207,7 +208,7 @@ void tst_QGestureRecognizer::pinchGesture()
|
||||
points.append(widget.rect().center());
|
||||
points.append(points.front() + QPoint(0, 20));
|
||||
|
||||
QTest::QTouchEventWidgetSequence pinchSequence = QTest::touchEvent(&widget, m_touchDevice);
|
||||
QTest::QTouchEventWidgetSequence pinchSequence = QTest::touchEvent(&widget, m_touchDevice.get());
|
||||
pressSequence(pinchSequence, points, &widget);
|
||||
|
||||
for (int s = 0; s < 5; ++s) {
|
||||
@ -264,7 +265,7 @@ void tst_QGestureRecognizer::swipeGesture()
|
||||
for (int i = 0; i < swipePoints - 1; ++i)
|
||||
points.append(fingerDistance + i * fingerDistance);
|
||||
|
||||
QTest::QTouchEventWidgetSequence swipeSequence = QTest::touchEvent(&widget, m_touchDevice);
|
||||
QTest::QTouchEventWidgetSequence swipeSequence = QTest::touchEvent(&widget, m_touchDevice.get());
|
||||
pressSequence(swipeSequence, points, &widget);
|
||||
|
||||
// Press point #3
|
||||
@ -315,8 +316,8 @@ void tst_QGestureRecognizer::touchReplay()
|
||||
|
||||
QWindow* windowHandle = parent.window()->windowHandle();
|
||||
const QPoint globalPos = QPoint(42, 16);
|
||||
QTest::touchEvent(windowHandle, m_touchDevice).press(1, globalPos);
|
||||
QTest::touchEvent(windowHandle, m_touchDevice).release(1, globalPos);
|
||||
QTest::touchEvent(windowHandle, m_touchDevice.get()).press(1, globalPos);
|
||||
QTest::touchEvent(windowHandle, m_touchDevice.get()).release(1, globalPos);
|
||||
|
||||
QVERIFY(widget.gestureReceived(gestureType));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user