aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickdeliveryagent.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2021-04-15 15:30:37 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2021-04-27 20:13:10 +0200
commit30013ccae388aa55b870aa70bc20979d7c434c05 (patch)
treede6aecb41d5acc48516694ccf487e89546c3c250 /src/quick/util/qquickdeliveryagent.cpp
parent832e3ab9497d16ab57953d5ab4e7d41fa831a848 (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 Pick-to: 6.1 Change-Id: I9bd8cfc2510168b6e14002957833b54eb9586ab0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/quick/util/qquickdeliveryagent.cpp')
-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 651aa598d8..45a7afda47 100644
--- a/src/quick/util/qquickdeliveryagent.cpp
+++ b/src/quick/util/qquickdeliveryagent.cpp
@@ -1519,9 +1519,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();
}
@@ -1571,6 +1574,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;
}