aboutsummaryrefslogtreecommitdiffstats
path: root/src
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-06-04 13:47:20 +0200
commit63b1f379b710c510f00311e03641aa65e72aaf34 (patch)
tree99519a8f79c65a722dcabb947683ffffcc97ff8b /src
parentcb293ee3afea3fe0cfabee58b4d34c278f17b709 (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 Pick-to: 6.1 Change-Id: I4c35f648be9513e5e237d9b8d4e502e40e9f8a76 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/quick/handlers/qquickpointerhandler.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/quick/handlers/qquickpointerhandler.cpp b/src/quick/handlers/qquickpointerhandler.cpp
index 495eb8b7d3..c1b20b1388 100644
--- a/src/quick/handlers/qquickpointerhandler.cpp
+++ b/src/quick/handlers/qquickpointerhandler.cpp
@@ -363,9 +363,10 @@ bool QQuickPointerHandler::approveGrabTransition(QPointerEvent *event, const QEv
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() &&
- (QQuickDeliveryAgentPrivate::isMouseEvent(event) || da->isDeliveringTouchAsMouse())) ||
+ (QQuickDeliveryAgentPrivate::isMouseEvent(event) || isTouchMouse)) ||
(existingItemGrabber->keepTouchGrab() && QQuickDeliveryAgentPrivate::isTouchEvent(event)))) {
allowed = false;
// If the handler wants to steal the exclusive grab from an Item, the Item can usually veto
@@ -378,7 +379,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;