From a0d615e3b6c36a6918f27c7b53081a2f53043e9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Fri, 2 Mar 2018 12:29:55 +0100 Subject: Don't crash if DragHandler have target: null Change-Id: Ie5c5367439f8773eb523ef5d639a018a2fd59c65 Reviewed-by: Shawn Rutledge --- src/quick/handlers/qquickdraghandler.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/quick/handlers/qquickdraghandler.cpp b/src/quick/handlers/qquickdraghandler.cpp index 60b57206d3..041780257a 100644 --- a/src/quick/handlers/qquickdraghandler.cpp +++ b/src/quick/handlers/qquickdraghandler.cpp @@ -108,15 +108,15 @@ QPointF QQuickDragHandler::localTargetPosition(QQuickEventPoint *point) void QQuickDragHandler::onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabState stateChange, QQuickEventPoint *point) { - if (!target() || !target()->parentItem()) - return; if (grabber == this && stateChange == QQuickEventPoint::GrabExclusive) { // In case the grab got handed over from another grabber, we might not get the Press. if (!m_pressedInsideTarget) { - m_pressTargetPos = QPointF(target()->width(), target()->height()) / 2; + if (target()) + m_pressTargetPos = QPointF(target()->width(), target()->height()) / 2; m_pressScenePos = point->scenePosition(); } else if (m_pressTargetPos.isNull()) { - m_pressTargetPos = localTargetPosition(point); + if (target()) + m_pressTargetPos = localTargetPosition(point); m_pressScenePos = point->scenePosition(); } } @@ -137,8 +137,10 @@ void QQuickDragHandler::handleEventPoint(QQuickEventPoint *point) point->setAccepted(); switch (point->state()) { case QQuickEventPoint::Pressed: - m_pressedInsideTarget = targetContains(point); - m_pressTargetPos = localTargetPosition(point); + if (target()) { + m_pressedInsideTarget = targetContains(point); + m_pressTargetPos = localTargetPosition(point); + } m_pressScenePos = point->scenePosition(); setPassiveGrab(point); break; -- cgit v1.2.3