From 2f397aa15a13efbadf6c1bc378bb134ac1e655c5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 23 Apr 2018 14:49:58 +0200 Subject: Fix crash when using drag with Drag.Automatic QQuickPointerTouchEvent::m_event is 0 when calling QQuickPointerTouchEvent::isPressEvent(). Add a convenience function with a check returning the Qt::TouchPointStates. Task-number: QTBUG-44976 Change-Id: I2433ec3c56adeda2de190ca46aed8413a1357c55 Reviewed-by: Shawn Rutledge --- src/quick/items/qquickevents.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/quick/items/qquickevents.cpp') diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp index 1be4bafe28..3343ea3fa7 100644 --- a/src/quick/items/qquickevents.cpp +++ b/src/quick/items/qquickevents.cpp @@ -1572,6 +1572,13 @@ void QQuickPointerTouchEvent::clearGrabbers() const { } } +Qt::TouchPointStates QQuickPointerTouchEvent::touchPointStates() const +{ + return m_event + ? static_cast(m_event)->touchPointStates() + : Qt::TouchPointStates(); +} + /*! Returns whether the given \a handler is the exclusive grabber of any touchpoint within this event. @@ -1586,17 +1593,17 @@ bool QQuickPointerTouchEvent::hasExclusiveGrabber(const QQuickPointerHandler *ha bool QQuickPointerTouchEvent::isPressEvent() const { - return static_cast(m_event)->touchPointStates() & Qt::TouchPointPressed; + return touchPointStates() & Qt::TouchPointPressed; } bool QQuickPointerTouchEvent::isUpdateEvent() const { - return static_cast(m_event)->touchPointStates() & (Qt::TouchPointMoved | Qt::TouchPointStationary); + return touchPointStates() & (Qt::TouchPointMoved | Qt::TouchPointStationary); } bool QQuickPointerTouchEvent::isReleaseEvent() const { - return static_cast(m_event)->touchPointStates() & Qt::TouchPointReleased; + return touchPointStates() & Qt::TouchPointReleased; } QVector QQuickPointerEvent::unacceptedPressedPointScenePositions() const -- cgit v1.2.3 From a6b740869d369dacb8700042aa5da35183a03b5a Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Wed, 9 May 2018 14:00:07 +0900 Subject: Fix build without features.gestures Change-Id: Id2fb6419be9a35ddaa24106d3022e72070cb908d Reviewed-by: Shawn Rutledge Reviewed-by: Oswald Buddenhagen --- src/quick/items/qquickevents.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/quick/items/qquickevents.cpp') diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp index 3343ea3fa7..d964f2bb32 100644 --- a/src/quick/items/qquickevents.cpp +++ b/src/quick/items/qquickevents.cpp @@ -1388,6 +1388,7 @@ void QQuickPointerTouchEvent::localize(QQuickItem *target) point->localizePosition(target); } +#if QT_CONFIG(gestures) QQuickPointerEvent *QQuickPointerNativeGestureEvent::reset(QEvent *event) { auto ev = static_cast(event); @@ -1417,6 +1418,7 @@ void QQuickPointerNativeGestureEvent::localize(QQuickItem *target) { m_gesturePoint->localizePosition(target); } +#endif // QT_CONFIG(gestures) QQuickEventPoint *QQuickPointerMouseEvent::point(int i) const { if (i == 0) @@ -1430,11 +1432,13 @@ QQuickEventPoint *QQuickPointerTouchEvent::point(int i) const { return nullptr; } +#if QT_CONFIG(gestures) QQuickEventPoint *QQuickPointerNativeGestureEvent::point(int i) const { if (i == 0) return m_gesturePoint; return nullptr; } +#endif // QT_CONFIG(gestures) QQuickEventPoint::QQuickEventPoint(QQuickPointerEvent *parent) : QObject(parent), m_pointId(0), m_exclusiveGrabber(nullptr), m_timestamp(0), m_pressTimestamp(0), @@ -1662,6 +1666,7 @@ QMouseEvent *QQuickPointerTouchEvent::syntheticMouseEvent(int pointID, QQuickIte return &m_synthMouseEvent; } +#if QT_CONFIG(gestures) /*! Returns the exclusive grabber of this event, if any, in a vector. */ @@ -1719,6 +1724,7 @@ qreal QQuickPointerNativeGestureEvent::value() const { return static_cast(m_event)->value(); } +#endif // QT_CONFIG(gestures) /*! \internal @@ -1742,12 +1748,13 @@ QQuickEventPoint *QQuickPointerTouchEvent::pointById(int pointId) const { return nullptr; } +#if QT_CONFIG(gestures) QQuickEventPoint *QQuickPointerNativeGestureEvent::pointById(int pointId) const { if (m_gesturePoint && pointId == m_gesturePoint->pointId()) return m_gesturePoint; return nullptr; } - +#endif /*! \internal @@ -1866,6 +1873,7 @@ QTouchEvent *QQuickPointerTouchEvent::asTouchEvent() const return static_cast(m_event); } +#if QT_CONFIG(gestures) bool QQuickPointerNativeGestureEvent::allPointsAccepted() const { return m_gesturePoint->isAccepted(); } @@ -1878,6 +1886,7 @@ bool QQuickPointerNativeGestureEvent::allPointsGrabbed() const { return m_gesturePoint->exclusiveGrabber() != nullptr; } +#endif // QT_CONFIG(gestures) #ifndef QT_NO_DEBUG_STREAM -- cgit v1.2.3 From 710f9507c0ebf01d9e9f717e676b9c3b1b94ee8a Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 7 May 2018 14:56:26 +0200 Subject: setGrabberItem: consistently call touchUngrabEvent or mouseUngrabEvent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calling grabberItem() to get the old grabber must come before setting m_exclusiveGrabber. Then we call oldGrabberItem->touchUngrabEvent() or oldGrabberItem->mouseUngrabEvent() as appropriate. Now the responsibility for this is moved from QQuickItem::grabMouse() to QQuickEventPoint::setGrabberItem() (which it calls). Task-number: QTBUG-65648 Change-Id: Ia6219cb798d7f671ccc4006d51eeb87dbdbda3ef Reviewed-by: Jan Arve Sæther --- src/quick/items/qquickevents.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/quick/items/qquickevents.cpp') diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp index d964f2bb32..d020ad7c4c 100644 --- a/src/quick/items/qquickevents.cpp +++ b/src/quick/items/qquickevents.cpp @@ -849,14 +849,16 @@ void QQuickEventPoint::setGrabberItem(QQuickItem *grabber) qCDebug(lcPointerGrab) << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this) << ": grab" << m_exclusiveGrabber << "->" << grabber; } + QQuickItem *oldGrabberItem = grabberItem(); m_exclusiveGrabber = QPointer(grabber); m_grabberIsHandler = false; m_sceneGrabPos = m_scenePos; - QQuickItem *oldGrabberItem = grabberItem(); - if (oldGrabberHandler) + if (oldGrabberHandler) { oldGrabberHandler->onGrabChanged(oldGrabberHandler, (grabber ? CancelGrabExclusive : UngrabExclusive), this); - else if (oldGrabberItem && oldGrabberItem != grabber && grabber && pointerEvent()->asPointerTouchEvent()) - oldGrabberItem->touchUngrabEvent(); + } else if (oldGrabberItem && oldGrabberItem != grabber && grabber && grabber->window()) { + QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(grabber->window()); + windowPriv->sendUngrabEvent(oldGrabberItem, windowPriv->isDeliveringTouchAsMouse()); + } for (QPointer passiveGrabber : m_passiveGrabbers) passiveGrabber->onGrabChanged(passiveGrabber, OverrideGrabPassive, this); } -- cgit v1.2.3