diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-04-23 14:49:58 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-04-26 20:49:48 +0000 |
commit | 2f397aa15a13efbadf6c1bc378bb134ac1e655c5 (patch) | |
tree | b3ff0e821eaa1c1abcb2280a04164d18017efaa2 | |
parent | 44e398f64ebe2841d5448076ed83f9886ab1b48f (diff) |
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 <shawn.rutledge@qt.io>
-rw-r--r-- | src/quick/items/qquickevents.cpp | 13 | ||||
-rw-r--r-- | src/quick/items/qquickevents_p_p.h | 2 |
2 files changed, 12 insertions, 3 deletions
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<QTouchEvent*>(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<QTouchEvent*>(m_event)->touchPointStates() & Qt::TouchPointPressed; + return touchPointStates() & Qt::TouchPointPressed; } bool QQuickPointerTouchEvent::isUpdateEvent() const { - return static_cast<QTouchEvent*>(m_event)->touchPointStates() & (Qt::TouchPointMoved | Qt::TouchPointStationary); + return touchPointStates() & (Qt::TouchPointMoved | Qt::TouchPointStationary); } bool QQuickPointerTouchEvent::isReleaseEvent() const { - return static_cast<QTouchEvent*>(m_event)->touchPointStates() & Qt::TouchPointReleased; + return touchPointStates() & Qt::TouchPointReleased; } QVector<QPointF> QQuickPointerEvent::unacceptedPressedPointScenePositions() const diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h index 2a1e9dc184..00ee0e18f9 100644 --- a/src/quick/items/qquickevents_p_p.h +++ b/src/quick/items/qquickevents_p_p.h @@ -510,6 +510,8 @@ public: QTouchEvent *asTouchEvent() const; private: + Qt::TouchPointStates touchPointStates() const; + int m_pointCount = 0; QVector<QQuickEventTouchPoint *> m_touchPoints; mutable QMouseEvent m_synthMouseEvent; |