aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickpincharea.cpp
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@jollamobile.com>2015-02-18 15:53:09 +1000
committerAaron McCarthy <mccarthy.aaron@gmail.com>2015-02-24 01:12:26 +0000
commit83a16630c13969e68cd3a5aaab73335ccb0d4414 (patch)
treec6b4728ab016a19545bc826b54a2f3f64d378341 /src/quick/items/qquickpincharea.cpp
parentcb0243d5078dcd9cebb2ce89621e4912ff57cebf (diff)
Handle TouchCancel events in QQuickPinchArea
QQuickPinchArea did not handle TouchCancel events and would recursively call QQuickItem::event(). Cancel the pinch gesture by restoring the pinch state to the start state. Don't recursively call QQuickItem::event(), instead call QQuickItem::touchEvent() for unhandled touch events. [ChangeLog][QtQuick][PinchArea] Fix infinite recursion when TouchCancel events are received. Change-Id: Ifce4af91aec4285873cb701069e007bcee180851 Reviewed-by: Martin Jones <martin.jones@qinetic.com.au>
Diffstat (limited to 'src/quick/items/qquickpincharea.cpp')
-rw-r--r--src/quick/items/qquickpincharea.cpp46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/quick/items/qquickpincharea.cpp b/src/quick/items/qquickpincharea.cpp
index 33f4bade3a..8a391b7aea 100644
--- a/src/quick/items/qquickpincharea.cpp
+++ b/src/quick/items/qquickpincharea.cpp
@@ -346,8 +346,11 @@ void QQuickPinchArea::touchEvent(QTouchEvent *event)
case QEvent::TouchEnd:
clearPinch();
break;
+ case QEvent::TouchCancel:
+ cancelPinch();
+ break;
default:
- QQuickItem::event(event);
+ QQuickItem::touchEvent(event);
}
}
@@ -384,6 +387,47 @@ void QQuickPinchArea::clearPinch()
setKeepMouseGrab(false);
}
+void QQuickPinchArea::cancelPinch()
+{
+ Q_D(QQuickPinchArea);
+
+ d->touchPoints.clear();
+ if (d->inPinch) {
+ d->inPinch = false;
+ QPointF pinchCenter = mapFromScene(d->sceneLastCenter);
+ QQuickPinchEvent pe(d->pinchStartCenter, d->pinchStartScale, d->pinchStartAngle, d->pinchStartRotation);
+ pe.setStartCenter(d->pinchStartCenter);
+ pe.setPreviousCenter(pinchCenter);
+ pe.setPreviousAngle(d->pinchLastAngle);
+ pe.setPreviousScale(d->pinchLastScale);
+ pe.setStartPoint1(mapFromScene(d->sceneStartPoint1));
+ pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));
+ pe.setPoint1(pe.startPoint1());
+ pe.setPoint2(pe.startPoint2());
+ emit pinchFinished(&pe);
+
+ d->pinchLastScale = d->pinchStartScale;
+ d->sceneLastCenter = d->sceneStartCenter;
+ d->pinchLastAngle = d->pinchStartAngle;
+ d->lastPoint1 = pe.startPoint1();
+ d->lastPoint2 = pe.startPoint2();
+ updatePinchTarget();
+
+ if (d->pinch && d->pinch->target())
+ d->pinch->setActive(false);
+ }
+ d->pinchStartDist = 0;
+ d->pinchActivated = false;
+ d->initPinch = false;
+ d->pinchRejected = false;
+ d->stealMouse = false;
+ d->id1 = -1;
+ QQuickWindow *win = window();
+ if (win && win->mouseGrabberItem() == this)
+ ungrabMouse();
+ setKeepMouseGrab(false);
+}
+
void QQuickPinchArea::updatePinch()
{
Q_D(QQuickPinchArea);