diff options
author | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2012-04-24 10:51:59 +0300 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-25 09:47:25 +0200 |
commit | b8bb9d7561b6be0557cde93ba3c5390a50f14087 (patch) | |
tree | 5b3760f5fb6591f9066bc0dc4fe178bab1354778 /src/quick/items/qquickcanvas.cpp | |
parent | 9b1299e0db11bc42acbbc95f24ef30640aecc930 (diff) |
Make touch event delivery in the canvas reentrant
At the moment the unlikely case of spinning the event loop from a
QQuickItem event handler for TouchBegin is not handled properly: It
will end up not delivering the subsequent TouchUpdate and TouchEnd
events to the item, leaving it in a state that should not normally
happen.
Change-Id: I668d065c9cf1a299bfd9268a9125d7a7e32f6786
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
Diffstat (limited to 'src/quick/items/qquickcanvas.cpp')
-rw-r--r-- | src/quick/items/qquickcanvas.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/quick/items/qquickcanvas.cpp b/src/quick/items/qquickcanvas.cpp index f4aa735ffd..0410658914 100644 --- a/src/quick/items/qquickcanvas.cpp +++ b/src/quick/items/qquickcanvas.cpp @@ -1493,14 +1493,19 @@ bool QQuickCanvasPrivate::deliverTouchPoints(QQuickItem *item, QTouchEvent *even touchEvent.setTouchPoints(eventPoints); touchEvent.setTimestamp(event->timestamp()); + for (int i = 0; i < matchingPoints.count(); ++i) + itemForTouchPointId[matchingPoints[i].id()] = item; + touchEvent.accept(); q->sendEvent(item, &touchEvent); if (touchEvent.isAccepted()) { - for (int i=0; i<matchingPoints.count(); i++) { - itemForTouchPointId[matchingPoints[i].id()] = item; + for (int i = 0; i < matchingPoints.count(); ++i) acceptedNewPoints->insert(matchingPoints[i].id()); - } + } else { + for (int i = 0; i < matchingPoints.count(); ++i) + if (itemForTouchPointId.value(matchingPoints[i].id()) == item) + itemForTouchPointId.remove(matchingPoints[i].id()); } } } |