diff options
author | Jan Arve Sæther <jan-arve.saether@qt.io> | 2017-11-23 10:56:06 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2017-11-24 12:55:31 +0000 |
commit | 6eabb3edf27e3b73205fa70e4497ce7ec1201adc (patch) | |
tree | c4056fc5271f41eff6f2d84f5e1fa7545160063b /src/quick/handlers/qquickdraghandler.cpp | |
parent | 2f91b0f25fff560de27632ec9d947c890426664e (diff) |
Fix a bug with calculation of translation in DragHandler
The problem was that the start position of the target item
(m_targetStartPos) was not always updated.
In combination with several handlers (this bug was observed with
PinchHandler and DragHandler as siblings) it is quite likely that the
DragHandler will get a press, but not activate (because the PinchHandler
might activate instead). It would therefore not deactivate (so it would
not reset m_targetStartPos), and as a consequence the m_targetStartPos was
not updated to its correct value the next time we initiated a drag because
m_targetStartPos wasn't null.
Change-Id: Icf3089fc685cfbcbcfba638966a2e8ad1c8c089f
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/handlers/qquickdraghandler.cpp')
-rw-r--r-- | src/quick/handlers/qquickdraghandler.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/quick/handlers/qquickdraghandler.cpp b/src/quick/handlers/qquickdraghandler.cpp index 12f1a29bca..d4a8f06db8 100644 --- a/src/quick/handlers/qquickdraghandler.cpp +++ b/src/quick/handlers/qquickdraghandler.cpp @@ -93,8 +93,9 @@ bool QQuickDragHandler::wantsEventPoint(QQuickEventPoint *point) void QQuickDragHandler::onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabState stateChange, QQuickEventPoint *point) { - if (grabber == this && stateChange == QQuickEventPoint::GrabExclusive) - // In case the grab got handled over from another grabber, we might not get the Press + if (grabber == this && stateChange == QQuickEventPoint::GrabExclusive && m_targetStartPos.isNull()) + // In case the grab got handled over from another grabber, we might not get the Press. + // Therefore, prefer the m_targetStartPos we got when it got Pressed. initializeTargetStartPos(point); enforceConstraints(); QQuickSinglePointHandler::onGrabChanged(grabber, stateChange, point); @@ -167,7 +168,7 @@ void QQuickDragHandler::enforceAxisConstraints(QPointF *localPos) void QQuickDragHandler::initializeTargetStartPos(QQuickEventPoint *point) { - if (target() && target()->parentItem() && m_targetStartPos.isNull()) { // prefer the m_targetStartPos we got when it got Pressed. + if (target() && target()->parentItem()) { m_targetStartPos = target()->parentItem()->mapToScene(target()->position()); if (!target()->contains(point->position())) { // If pressed outside of target item, move the target item so that the touchpoint is in its center, |