diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-11-16 15:00:08 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-11-19 21:32:45 +0100 |
commit | 18c2b4f6dbdc0e0d7e235c2547394d4dafa6dd41 (patch) | |
tree | bf20b77f7e050c5fef600bd1288c6c5c05ab0783 /src/quick/items/qquickflickable.cpp | |
parent | fd9e4920b3d8235061d2bde19bca7ded566f6331 (diff) |
Make sure we don't modify the incoming event objects when localizing
Restore the position of the single event point after event delivery.
Where possible, don't make a localized copy which explicitly shares
its data with the original anyway. Instead, access the original
directly.
Change-Id: I5efa44c336eddeef1a1ab00dc91e2d0f223ed31d
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/items/qquickflickable.cpp')
-rw-r--r-- | src/quick/items/qquickflickable.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index b451c275c2..2401f008aa 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -1452,9 +1452,12 @@ void QQuickFlickable::mouseReleaseEvent(QMouseEvent *event) // Now send the release if (auto grabber = qmlobject_cast<QQuickItem *>(event->exclusiveGrabber(event->point(0)))) { - QMutableSinglePointEvent localized(*event); - localized.mutablePoint().setPosition(grabber->mapFromScene(localized.scenePosition())); - QCoreApplication::sendEvent(window(), &localized); + // not copying or detaching anything, so make sure we return the original event unchanged + QMutableSinglePointEvent *localized = QMutableSinglePointEvent::from(event); + const auto oldPosition = localized->mutablePoint().position(); + localized->mutablePoint().setPosition(grabber->mapFromScene(localized->scenePosition())); + QCoreApplication::sendEvent(window(), localized); + localized->mutablePoint().setPosition(oldPosition); } // And the event has been consumed |