aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2022-04-29 15:18:08 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2022-05-03 21:17:44 +0200
commitd4021a8d62287219a4be9fbd555b9ba91130737a (patch)
tree575b22e3f334adcca3d0cd2462bdac52a36055cd /src/quick/items
parent68eabf398aa5acd683f3b0ca860fed73218aaf1b (diff)
MouseArea: don't get stuck in doubleClick if handler caused ungrab
The bug scenario went like this: 1) QQuickMouseArea::mouseDoubleClickEvent() emits doubleClicked 2) onDoubleClicked in QML hid the MouseArea somehow 3) QQuickMouseArea::ungrabMouse() is called; it sets d->pressed = Qt::NoButton and d->doubleClick = false (and others) 4) eventually we get back to the continuation of mouseDoubleClickEvent() which sets d->doubleClick back to true 5) mouse release: this MouseArea is not involved (no grab anymore) 6) next mouse press: QQuickMouseArea::setPressed() has if (!d->doubleClick) emit pressed(&me); pressed() is not emitted because of leftover state So either we need to avoid setting d->doubleClick to true if d->pressed has been set to Qt::NoButton in QQuickMouseArea::ungrabMouse(); or else we should reorder the statements in mouseDoubleClickEvent() to set d->doubleClick before emitting doubleClicked, so that it will not be overridden after the QML handler is called. This patch takes the first approach. Fixes: QTBUG-35995 Fixes: QTBUG-102158 Change-Id: Ibe5c9bfbc9c7a70772dd5ebfbc9ce401c6c226d3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 089c3b15b95fc0ddbf2385378f96702a999771c8)
Diffstat (limited to 'src/quick/items')
-rw-r--r--src/quick/items/qquickmousearea.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp
index 39e0652605..7f5272a142 100644
--- a/src/quick/items/qquickmousearea.cpp
+++ b/src/quick/items/qquickmousearea.cpp
@@ -825,7 +825,8 @@ void QQuickMouseArea::mouseDoubleClickEvent(QMouseEvent *event)
emit this->doubleClicked(&me);
if (!me.isAccepted())
d->propagate(&me, QQuickMouseAreaPrivate::DoubleClick);
- d->doubleClick = d->isDoubleClickConnected() || me.isAccepted();
+ if (d->pressed)
+ d->doubleClick = d->isDoubleClickConnected() || me.isAccepted();
}
QQuickItem::mouseDoubleClickEvent(event);
}