diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-11-23 16:57:39 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-12-07 20:45:41 +0000 |
commit | be3772725cec64e533d35a38376077363af01ede (patch) | |
tree | f6d664d3b4dc36edb9cf73ba4b64bd80e36a548e /src | |
parent | ee2ac69595d3f854f7bf7158e600091f2675fa18 (diff) |
Ensure that each Event Handler has an Item parent rather than asserting
QQuickItemPrivate::data_append() was already getting called, but the
assert (that the parent was already an Item) was failing in case a
handler was declared inside a Window or a Dialog.
Fixes: QTBUG-71317
Change-Id: Ia497182e3b4a9722eee97a375f9ee5d4151108e6
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/qquickitem.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 015fe66202..fabd3ef03b 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,7 +3281,10 @@ 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); + 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); |