summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2021-04-15 15:30:37 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-04-27 19:36:27 +0000
commita4042b00468a245d9109d833b8a00700c835386b (patch)
tree7878f125b5ae6147ad47c04be42ef61eae562c86
parent26225f19cce7bfcec6b0946a2436e7ad2a38e78c (diff)
Restore scene position after changing it during delivery
When we visit multiple subscenes via multiple DAs, if they are changing the scene pos, the original gets lost, and then maybe we visit some handler via the root DA again (like a TapHandler declared in a View3D). This helps to fix qtquick3d/examples/quick3d/dynamictexture Task-number: QTBUG-92944 Change-Id: I9bd8cfc2510168b6e14002957833b54eb9586ab0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 30013ccae388aa55b870aa70bc20979d7c434c05) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/quick/util/qquickdeliveryagent.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/quick/util/qquickdeliveryagent.cpp b/src/quick/util/qquickdeliveryagent.cpp
index 2fd5cab9a2..332b6a8537 100644
--- a/src/quick/util/qquickdeliveryagent.cpp
+++ b/src/quick/util/qquickdeliveryagent.cpp
@@ -1518,9 +1518,12 @@ void QQuickDeliveryAgentPrivate::deliverPointerEvent(QPointerEvent *event)
// updates get delivered here pretty directly, bypassing picking; but we need to
// be able to map the 2D viewport coordinate to a 2D coordinate within
// d->rootItem, a 2D scene that has been arbitrarily mapped onto a 3D object.
+ QVarLengthArray<QPointF, 16> originalScenePositions;
if (sceneTransform) {
+ originalScenePositions.resize(event->pointCount());
for (int i = 0; i < event->pointCount(); ++i) {
auto &mut = QMutableEventPoint::from(event->point(i));
+ originalScenePositions[i] = mut.scenePosition();
mut.setScenePosition(sceneTransform->map(mut.scenePosition()));
qCDebug(lcPtrLoc) << q << event->type() << mut.id() << "transformed scene pos" << mut.scenePosition();
}
@@ -1570,6 +1573,10 @@ void QQuickDeliveryAgentPrivate::deliverPointerEvent(QPointerEvent *event)
}
eventsInDelivery.pop();
+ if (sceneTransform) {
+ for (int i = 0; i < event->pointCount(); ++i)
+ QMutableEventPoint::from(event->point(i)).setScenePosition(originalScenePositions.at(i));
+ }
--pointerEventRecursionGuard;
lastUngrabbed = nullptr;
}