diff options
author | Jan Arve Sæther <jan-arve.saether@qt.io> | 2018-09-10 16:30:26 +0200 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@qt.io> | 2018-09-11 11:45:18 +0000 |
commit | 0431e462dff57bc6a9010649c0d7f153d91cab2d (patch) | |
tree | 435ad3a647040f0f568d19dd58ad43b8c465ce6d | |
parent | 72cc53b5ee8bd6821d0094ad0c5c45d7a269f943 (diff) |
-rw-r--r-- | src/quick/items/qquickevents_p_p.h | 2 | ||||
-rw-r--r-- | src/quick/items/qquickwindow.cpp | 21 |
2 files changed, 13 insertions, 10 deletions
diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h index 3f70ad8c2d..4097845ec9 100644 --- a/src/quick/items/qquickevents_p_p.h +++ b/src/quick/items/qquickevents_p_p.h @@ -429,7 +429,7 @@ public: // helpers for C++ only (during event delivery) virtual bool allUpdatedPointsAccepted() const = 0; virtual bool allPointsGrabbed() const = 0; bool isAccepted() { return m_event->isAccepted(); } - void setAccepted(bool accepted) { m_event->setAccepted(accepted); } + void setAccepted(bool accepted) { if (m_event) m_event->setAccepted(accepted); } QVector<QPointF> unacceptedPressedPointScenePositions() const; virtual int pointCount() const = 0; diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index d9db8b56b4..5cd04decf7 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -690,8 +690,8 @@ bool QQuickWindowPrivate::deliverTouchAsMouse(QQuickItem *item, QQuickPointerEve touchMouseId = p.id(); if (!q->mouseGrabberItem()) item->grabMouse(); - auto pointerEventPoint = pointerEvent->pointById(p.id()); - pointerEventPoint->setGrabberItem(item); + if (auto pointerEventPoint = pointerEvent->pointById(p.id())) + pointerEventPoint->setGrabberItem(item); if (checkIfDoubleClicked(event->timestamp())) { QScopedPointer<QMouseEvent> mouseDoubleClick(touchToMouseEvent(QEvent::MouseButtonDblClick, p, event.data(), item, false)); @@ -2607,19 +2607,22 @@ void QQuickWindowPrivate::deliverMatchingPointsToItem(QQuickItem *item, QQuickPo // update accepted new points. bool isPressOrRelease = pointerEvent->isPressEvent() || pointerEvent->isReleaseEvent(); for (auto point: qAsConst(touchEvent->touchPoints())) { - auto pointerEventPoint = ptEvent->pointById(point.id()); - pointerEventPoint->setAccepted(); - if (isPressOrRelease) - pointerEventPoint->setGrabberItem(item); + if (auto pointerEventPoint = ptEvent->pointById(point.id())) { + pointerEventPoint->setAccepted(); + if (isPressOrRelease) + pointerEventPoint->setGrabberItem(item); + } } } else { // But if the event was not accepted then we know this item // will not be interested in further updates for those touchpoint IDs either. for (auto point: qAsConst(touchEvent->touchPoints())) { if (point.state() == Qt::TouchPointPressed) { - if (ptEvent->pointById(point.id())->exclusiveGrabber() == item) { - qCDebug(DBG_TOUCH_TARGET) << "TP" << hex << point.id() << "disassociated"; - ptEvent->pointById(point.id())->setGrabberItem(nullptr); + if (auto *tp = ptEvent->pointById(point.id())) { + if (tp->exclusiveGrabber() == item) { + qCDebug(DBG_TOUCH_TARGET) << "TP" << hex << point.id() << "disassociated"; + tp->setGrabberItem(nullptr); + } } } } |