aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers/qquickpointerhandler.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2021-05-25 19:25:25 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2021-05-26 14:46:39 +0200
commit2d1ec2f84953f93fb661d442cd4207e7f0198e4b (patch)
tree7425d58e02d024e7b2129851dc9d0aedbf477768 /src/quick/handlers/qquickpointerhandler.cpp
parent348085dd7d1aeb83628eeb9687d70b0ba595dacd (diff)
PointerHandler constructor: add to Item parent's list of handlers
When a pointer handler is created in C++, a parent Item might be given to the constructor, so QQuickItemPrivate::data_append() might not be called. But to be functional, it needs to be added to ExtraData.pointerHandlers. Task-number: QTBUG-68110 Change-Id: I02f6574f801018b964ecf4167bac65792d9c6094 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/quick/handlers/qquickpointerhandler.cpp')
-rw-r--r--src/quick/handlers/qquickpointerhandler.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/quick/handlers/qquickpointerhandler.cpp b/src/quick/handlers/qquickpointerhandler.cpp
index bed6449c6b..9fc7f45b7c 100644
--- a/src/quick/handlers/qquickpointerhandler.cpp
+++ b/src/quick/handlers/qquickpointerhandler.cpp
@@ -65,6 +65,13 @@ Q_LOGGING_CATEGORY(lcPointerHandlerActive, "qt.quick.handler.active")
QQuickPointerHandler::QQuickPointerHandler(QQuickItem *parent)
: QObject(*(new QQuickPointerHandlerPrivate), parent)
{
+ // When a handler is created in QML, the given parent is null, and we
+ // depend on QQuickItemPrivate::data_append() later when it's added to an
+ // item's DefaultProperty data property. But when a handler is created in
+ // C++ with a parent item, data_append() won't be called, and the caller
+ // shouldn't have to worry about it either.
+ if (parent)
+ QQuickItemPrivate::get(parent)->addPointerHandler(this);
}
QQuickPointerHandler::QQuickPointerHandler(QQuickPointerHandlerPrivate &dd, QQuickItem *parent)