aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickevents.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2017-03-07 17:10:43 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2017-03-08 13:11:23 +0000
commit3b3c8103496f61ebc4b72e73035a4d43fcdd03b0 (patch)
tree76bcd2a06da851b94984a50a4e137155bfac682c /src/quick/items/qquickevents.cpp
parent54bb88bc99a0ea3966b6bde2ba06e4ece237a32c (diff)
PointerHandlers: fix some grab notification and signal order problems
The singlePointHandlerProperties manual test showed how this was broken in a couple of ways after 8c659c6c723e4f5f97f46a4555a4765e85c26f1d : - When QQuickPointerTouchEvent::reset() is swapping one point instance for another, and consequently transferring the grabbers from one to another, it should not cause onGrabChanged to occur. Every point update was triggering DragHandler.onGrabChanged. - The order of signal emission is important so that sceneGrabPos will be correct in onGrabChanged. Change-Id: I62a302d6e54126ae10834b6d622e82aa0e434bab Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/quick/items/qquickevents.cpp')
-rw-r--r--src/quick/items/qquickevents.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp
index 49ed0f050e..61d843210e 100644
--- a/src/quick/items/qquickevents.cpp
+++ b/src/quick/items/qquickevents.cpp
@@ -650,6 +650,10 @@ void QQuickEventPoint::setGrabberPointerHandler(QQuickPointerHandler *grabber, b
if (exclusive) {
if (grabber != m_exclusiveGrabber.data()) {
if (grabber) {
+ // set variables before notifying the new grabber
+ m_exclusiveGrabber = QPointer<QObject>(grabber);
+ m_grabberIsHandler = true;
+ m_sceneGrabPos = m_scenePos;
grabber->onGrabChanged(grabber, GrabExclusive, this);
for (QPointer<QQuickPointerHandler> passiveGrabber : m_passiveGrabbers) {
if (passiveGrabber != grabber)
@@ -664,7 +668,7 @@ void QQuickEventPoint::setGrabberPointerHandler(QQuickPointerHandler *grabber, b
if (pointerEvent()->asPointerTouchEvent())
oldGrabberItem->touchUngrabEvent();
}
-
+ // set variables after notifying the old grabber
m_exclusiveGrabber = QPointer<QObject>(grabber);
m_grabberIsHandler = true;
m_sceneGrabPos = m_scenePos;
@@ -943,8 +947,9 @@ QQuickPointerEvent *QQuickPointerTouchEvent::reset(QEvent *event)
point->setGrabberItem(nullptr);
point->clearPassiveGrabbers();
} else {
- point->setExclusiveGrabber(grabbers.at(i));
- point->setPassiveGrabbers(passiveGrabberses.at(i));
+ // Restore the grabbers without notifying (don't call onGrabChanged)
+ point->m_exclusiveGrabber = grabbers.at(i);
+ point->m_passiveGrabbers = passiveGrabberses.at(i);
}
}
m_pointCount = newPointCount;