aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers/qquickdraghandler.cpp
diff options
context:
space:
mode:
authorJan Arve Sæther <jan-arve.saether@qt.io>2018-03-02 12:29:55 +0100
committerJan Arve Sæther <jan-arve.saether@qt.io>2018-03-02 11:49:37 +0000
commita0d615e3b6c36a6918f27c7b53081a2f53043e9b (patch)
tree5a2af761a7352b7e11b404ccdae66b9c82c22d79 /src/quick/handlers/qquickdraghandler.cpp
parent440a15c52d979cc0221217480720978d55935c0d (diff)
Don't crash if DragHandler have target: null
Change-Id: Ie5c5367439f8773eb523ef5d639a018a2fd59c65 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/handlers/qquickdraghandler.cpp')
-rw-r--r--src/quick/handlers/qquickdraghandler.cpp14
1 files 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;