aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickitem.cpp
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-12-12 01:00:38 +0100
committerUlf Hermann <ulf.hermann@qt.io>2018-12-12 13:08:25 +0100
commit39643ef86e8bc48b8b6cf83ac0ebae7411029030 (patch)
tree79277e468160ebc04a65a85c9668dabefbf3ce33 /src/quick/items/qquickitem.cpp
parent489d6c28dda51c187c85017e30c1e018420e26ac (diff)
parente3446c8225acbaa6a613d6c62e8e2fc58e2b70b0 (diff)
Merge remote-tracking branch 'origin/5.12' into dev
Conflicts: tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp Change-Id: Ic1dace832ad4b29023d24808b8617b5dcc915eb5
Diffstat (limited to 'src/quick/items/qquickitem.cpp')
-rw-r--r--src/quick/items/qquickitem.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index f58e08038f..0cd4c446d9 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -89,6 +89,7 @@ QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(DBG_MOUSE_TARGET)
Q_DECLARE_LOGGING_CATEGORY(DBG_HOVER_TRACE)
Q_DECLARE_LOGGING_CATEGORY(lcTransient)
+Q_LOGGING_CATEGORY(lcHandlerParent, "qt.quick.handler.parent")
void debugFocusTree(QQuickItem *item, QQuickItem *scope = nullptr, int depth = 1)
{
@@ -3280,12 +3281,11 @@ void QQuickItemPrivate::data_append(QQmlListProperty<QObject> *prop, QObject *o)
if (o->inherits("QGraphicsItem"))
qWarning("Cannot add a QtQuick 1.0 item (%s) into a QtQuick 2.0 scene!", o->metaObject()->className());
else if (QQuickPointerHandler *pointerHandler = qmlobject_cast<QQuickPointerHandler *>(o)) {
- Q_ASSERT(pointerHandler->parentItem() == that);
- // Accept all buttons, and leave filtering to pointerEvent() and/or user JS,
- // because there can be multiple handlers...
- that->setAcceptedMouseButtons(Qt::AllButtons);
- QQuickItemPrivate *p = QQuickItemPrivate::get(that);
- p->extra.value().pointerHandlers.prepend(pointerHandler);
+ if (pointerHandler->parent() != that) {
+ qCDebug(lcHandlerParent) << "reparenting handler" << pointerHandler << ":" << pointerHandler->parent() << "->" << that;
+ pointerHandler->setParent(that);
+ }
+ QQuickItemPrivate::get(that)->addPointerHandler(pointerHandler);
} else {
QQuickWindow *thisWindow = qmlobject_cast<QQuickWindow *>(o);
QQuickItem *item = that;
@@ -8209,6 +8209,17 @@ bool QQuickItemPrivate::hasHoverHandlers() const
return false;
}
+void QQuickItemPrivate::addPointerHandler(QQuickPointerHandler *h)
+{
+ Q_Q(QQuickItem);
+ // Accept all buttons, and leave filtering to pointerEvent() and/or user JS,
+ // because there can be multiple handlers...
+ q->setAcceptedMouseButtons(Qt::AllButtons);
+ auto &handlers = extra.value().pointerHandlers;
+ if (!handlers.contains(h))
+ handlers.prepend(h);
+}
+
#if QT_CONFIG(quick_shadereffect)
QQuickItemLayer::QQuickItemLayer(QQuickItem *item)
: m_item(item)