diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/3rdparty/masm/stubs/wtf/Optional.h | 3 | ||||
-rw-r--r-- | src/quick/items/qquickitem.cpp | 23 | ||||
-rw-r--r-- | src/quick/items/qquickitem_p.h | 1 | ||||
-rw-r--r-- | src/quick/items/qquickitemsmodule.cpp | 16 |
4 files changed, 29 insertions, 14 deletions
diff --git a/src/3rdparty/masm/stubs/wtf/Optional.h b/src/3rdparty/masm/stubs/wtf/Optional.h index fdb7de51ce..602dbc1b43 100644 --- a/src/3rdparty/masm/stubs/wtf/Optional.h +++ b/src/3rdparty/masm/stubs/wtf/Optional.h @@ -84,7 +84,8 @@ private: #endif -#if __cplusplus < 201402L && !QT_CONFIG(cxx14_make_unique) +#if __cplusplus < 201402L && !QT_CONFIG(cxx14_make_unique)\ +&& !defined(__cpp_lib_make_unique) namespace std { template<typename T, class ...Args> diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 064406ee3c..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,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; @@ -8207,6 +8207,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) diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h index 11b47114cf..4ca3a01d02 100644 --- a/src/quick/items/qquickitem_p.h +++ b/src/quick/items/qquickitem_p.h @@ -281,6 +281,7 @@ public: bool hasPointerHandlers() const; bool hasHoverHandlers() const; + void addPointerHandler(QQuickPointerHandler *h); // data property static void data_append(QQmlListProperty<QObject> *, QObject *); diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp index a20150e3b9..b2fcfb4307 100644 --- a/src/quick/items/qquickitemsmodule.cpp +++ b/src/quick/items/qquickitemsmodule.cpp @@ -145,6 +145,7 @@ static QQmlPrivate::AutoParentResult qquickitem_autoParent(QObject *obj, QObject return QQmlPrivate::Parented; } } else if (QQuickPointerHandler *handler = qmlobject_cast<QQuickPointerHandler *>(obj)) { + QQuickItemPrivate::get(parentItem)->addPointerHandler(handler); handler->setParent(parent); return QQmlPrivate::Parented; } @@ -156,13 +157,14 @@ static QQmlPrivate::AutoParentResult qquickitem_autoParent(QObject *obj, QObject qCDebug(lcTransient) << win << "is transient for" << parentWindow; win->setTransientParent(parentWindow); return QQmlPrivate::Parented; - } else { - QQuickItem *item = qmlobject_cast<QQuickItem *>(obj); - if (item) { - // The parent of an Item inside a Window is actually the implicit content Item - item->setParentItem(parentWindow->contentItem()); - return QQmlPrivate::Parented; - } + } else if (QQuickItem *item = qmlobject_cast<QQuickItem *>(obj)) { + // The parent of an Item inside a Window is actually the implicit content Item + item->setParentItem(parentWindow->contentItem()); + return QQmlPrivate::Parented; + } else if (QQuickPointerHandler *handler = qmlobject_cast<QQuickPointerHandler *>(obj)) { + QQuickItemPrivate::get(parentWindow->contentItem())->addPointerHandler(handler); + handler->setParent(parentWindow->contentItem()); + return QQmlPrivate::Parented; } return QQmlPrivate::IncompatibleObject; } else if (qmlobject_cast<QQuickItem *>(obj)) { |