diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2010-02-12 15:18:07 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2010-02-16 09:54:04 (GMT) |
commit | f3a47f0fe6e9f63c030e6e89f1258d4faf2025cd (patch) | |
tree | 4e0316577caa4e7d91d4c9048fe3773d6751ecfb /src/gui | |
parent | 435fa2dbc44868f6ac81956be82631a2040ed1cc (diff) | |
download | Qt-f3a47f0fe6e9f63c030e6e89f1258d4faf2025cd.zip Qt-f3a47f0fe6e9f63c030e6e89f1258d4faf2025cd.tar.gz Qt-f3a47f0fe6e9f63c030e6e89f1258d4faf2025cd.tar.bz2 |
Don't crash when QTouchEvent is accepted but not handled by a
QGraphicsItem
After propagating QEvent::TouchBegin, if there is no item that has
accepted and handled the event, we must remove the touch point from our
data structures.
In this situation, QGraphicsScene will ignore the TouchBegin, as will
QGraphicsView, and QApplication will respond by not sending any more
touch events to the view/scene/item. This means our logic for handling
TouchPointReleased points will never be called (and the QGraphicsScene's
itemForTouchPointId and sceneCurrentTouchPoints state will be
incorrect).
Reviewed-by: Denis Dzyubenko
Reviewed-by: Marius Storm-Olsen
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 86aaa78..4472272 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -5712,8 +5712,15 @@ void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent) item->d_ptr->acceptedTouchBeginEvent = true; bool res = sendTouchBeginEvent(item, &touchEvent) && touchEvent.isAccepted(); - if (!res) + if (!res) { + // forget about these touch points, we didn't handle them + for (int i = 0; i < touchEvent.touchPoints().count(); ++i) { + const QTouchEvent::TouchPoint &touchPoint = touchEvent.touchPoints().at(i); + itemForTouchPointId.remove(touchPoint.id()); + sceneCurrentTouchPoints.remove(touchPoint.id()); + } ignoreSceneTouchEvent = false; + } break; } default: |