summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-08-29 11:10:16 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2021-08-30 19:34:50 +0000
commit6e2a5312db6ec933910407fe47c9d73d3170d0af (patch)
tree87666ced50c3c0ea06d15f180261726dfa774510
parentd9381bc7c36bf31d9496e20425968dafeee855be (diff)
Revert "Forward touchEvents to children inside QGraphicsProxyWidget"
This reverts commit 1ecf2212fae176b78c9951a37df9e33eb24d4f2d. The fix is not correct after all. TouchBegin goes to the correct widget with the fix, but following TouchUpdate and TouchEnd events now go to the viewport, as QApplication::translateRawTouchEvent always gives precedence to the widget that Qt recorded to be the touch grabber, which is the viewport. This results in infinite recursion, as the proxy widget trying to send the touch events to the embedded widget (expecting that translateRawTouchEvent will split it up) ends up sending the events back to the viewport. Leave the added test case as QEXPECT_FAIL, reactivate the (never run, hence unnoticed) test that the fix broke. Pick-to: 6.2 6.1 Task-number: QTBUG-45737 Task-number: QTBUG-67819 Change-Id: I4810affb3cd066743ae94ab7beb2f0c06b60d211 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget.cpp13
-rw-r--r--src/widgets/kernel/qapplication.cpp8
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp3
3 files changed, 10 insertions, 14 deletions
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
index 9a577455a6..4ffc06c513 100644
--- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
@@ -922,13 +922,14 @@ bool QGraphicsProxyWidget::event(QEvent *event)
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
case QEvent::TouchEnd: {
- QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
- auto touchPoints = touchEvent->points();
- bool res = QApplicationPrivate::translateRawTouchEvent(d->widget, touchEvent);
- if (res) {
- event->accept();
+ if (event->spontaneous())
+ qt_sendSpontaneousEvent(d->widget, event);
+ else
+ QCoreApplication::sendEvent(d->widget, event);
+
+ if (event->isAccepted())
return true;
- }
+
break;
}
default:
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 6dba04d284..4c704f3946 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -4020,9 +4020,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, const QTouchEv
{
// if the TouchBegin handler recurses, we assume that means the event
// has been implicitly accepted and continue to send touch events
- bool res = te->spontaneous() ? QApplication::sendSpontaneousEvent(widget, &touchEvent)
- : QApplication::sendEvent(widget, &touchEvent);
- if (res && touchEvent.isAccepted()) {
+ if (QApplication::sendSpontaneousEvent(widget, &touchEvent) && touchEvent.isAccepted()) {
accepted = true;
if (!widget.isNull())
widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent);
@@ -4035,9 +4033,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, const QTouchEv
|| QGestureManager::gesturePending(widget)
#endif
) {
- bool res = te->spontaneous() ? QApplication::sendSpontaneousEvent(widget, &touchEvent)
- : QApplication::sendEvent(widget, &touchEvent);
- if (res && touchEvent.isAccepted())
+ if (QApplication::sendSpontaneousEvent(widget, &touchEvent) && touchEvent.isAccepted())
accepted = true;
// widget can be deleted on TouchEnd
if (touchEvent.type() == QEvent::TouchEnd && !widget.isNull())
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index 4bd0dd0a8c..a2c7a6bf4b 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -3782,8 +3782,6 @@ void tst_QGraphicsProxyWidget::wheelEventPropagation()
// QTBUG_45737
void tst_QGraphicsProxyWidget::forwardTouchEvent()
{
- QSKIP("Test is currently broken");
-
QGraphicsScene scene;
TouchWidget *widget = new TouchWidget;
@@ -3931,6 +3929,7 @@ void tst_QGraphicsProxyWidget::touchEventPropagation()
sequence.press(0, pushButton1->pos() + pb1Center + formProxy->pos().toPoint());
}
// ..., formProxy, pushButton1, formWidget
+ QEXPECT_FAIL("", "Touch events are not forwarded to children - QTBUG-67819", Abort);
QCOMPARE(eventSpy.count(), 6);
record = eventSpy.at(eventSpy.count() - 2);
QCOMPARE(record.receiver, pushButton1);