aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2021-06-04 13:17:40 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2021-09-29 20:29:35 +0200
commitfeb076d23ed832b21bf415032146570f4afb25d5 (patch)
tree1f532e14276a12af0f9c666576b91be5360b525d
parent310d59b40c565f61cdcff805674c57caaa44aafb (diff)
Check for null pointer in QQuickPointerHandler::approveGrabTransition()
Found by static analysis: https://testresults.qt.io/codechecker/daily_diffs/qtdeclarative/dev/qtdeclarative-dev-20210604-1285b67a11/qquickpointerhandler.cpp_51058486.html#reportHash=9b76a76200c3a2eceb0e115776dda98b Amends b09ce7dcd8ecf24ef23da8197a64e3fced3fc894 Change-Id: I4c35f648be9513e5e237d9b8d4e502e40e9f8a76 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 63b1f379b710c510f00311e03641aa65e72aaf34) Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
-rw-r--r--src/quick/handlers/qquickpointerhandler.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/quick/handlers/qquickpointerhandler.cpp b/src/quick/handlers/qquickpointerhandler.cpp
index b33b95eec1..12b064a79b 100644
--- a/src/quick/handlers/qquickpointerhandler.cpp
+++ b/src/quick/handlers/qquickpointerhandler.cpp
@@ -353,10 +353,13 @@ bool QQuickPointerHandler::approveGrabTransition(QPointerEvent *event, const QEv
} else if ((d->grabPermissions & CanTakeOverFromItems)) {
allowed = true;
QQuickItem * existingItemGrabber = qobject_cast<QQuickItem *>(event->exclusiveGrabber(point));
- auto da = QQuickItemPrivate::get(parentItem())->deliveryAgentPrivate();
+ auto da = parentItem() ? QQuickItemPrivate::get(parentItem())->deliveryAgentPrivate()
+ : QQuickDeliveryAgentPrivate::currentEventDeliveryAgent ? static_cast<QQuickDeliveryAgentPrivate *>(
+ QQuickDeliveryAgentPrivate::get(QQuickDeliveryAgentPrivate::currentEventDeliveryAgent)) : nullptr;
+ const bool isTouchMouse = (da && da->isDeliveringTouchAsMouse());
if (existingItemGrabber &&
((existingItemGrabber->keepMouseGrab() &&
- (QQuickWindowPrivate::isMouseEvent(event) || da->isDeliveringTouchAsMouse())) ||
+ (QQuickWindowPrivate::isMouseEvent(event) || isTouchMouse)) ||
(existingItemGrabber->keepTouchGrab() && QQuickWindowPrivate::isTouchEvent(event)))) {
allowed = false;
// If the handler wants to steal the exclusive grab from an Item, the Item can usually veto
@@ -369,7 +372,7 @@ bool QQuickPointerHandler::approveGrabTransition(QPointerEvent *event, const QEv
if (existingItemGrabber->keepMouseGrab() &&
existingItemGrabber->filtersChildMouseEvents() && existingItemGrabber->isAncestorOf(parentItem())) {
Q_ASSERT(da);
- if (da->isDeliveringTouchAsMouse() && point.id() == da->touchMouseId) {
+ if (isTouchMouse && point.id() == da->touchMouseId) {
qCDebug(lcPointerHandlerGrab) << this << "steals touchpoint" << point.id()
<< "despite parent touch-mouse grabber with keepMouseGrab=true" << existingItemGrabber;
allowed = true;