From a4042b00468a245d9109d833b8a00700c835386b Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 15 Apr 2021 15:30:37 +0200 Subject: 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 (cherry picked from commit 30013ccae388aa55b870aa70bc20979d7c434c05) Reviewed-by: Qt Cherry-pick Bot --- src/quick/util/qquickdeliveryagent.cpp | 7 +++++++ 1 file changed, 7 insertions(+) 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 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; } -- cgit v1.2.3