diff options
| author | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-10-31 14:51:19 +0100 |
|---|---|---|
| committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2022-11-01 12:47:57 +0100 |
| commit | 02af6d91606efa3b2115c2d31adb4f29b2e60869 (patch) | |
| tree | 372561bc8b44fe601649c7731db496c0585973d8 | |
| parent | eca92bea571cf691423b627d4d6270f7c2807bd9 (diff) | |
Check only for enabled HoverHandlers
QQuickItemPrivate::hasHoverHandlers() was used only in
QQuickItemPrivate::setHasHoverInChild(). In that context it's ok to
ignore disabled HoverHandler instances: the point is we don't need to
deliver hover events to an item subtree if nobody is listening.
Change-Id: Ie44b6e259db862161a28ab5b7d1e910dc6ca4640
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 570a0fbc57a24116d47da056743961af06e50f86)
| -rw-r--r-- | src/quick/items/qquickitem.cpp | 6 | ||||
| -rw-r--r-- | src/quick/items/qquickitem_p.h | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 85ed95340c..05d4a873f2 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -7880,7 +7880,7 @@ void QQuickItemPrivate::setHasHoverInChild(bool hasHover) QQuickItemPrivate *otherChildPrivate = QQuickItemPrivate::get(otherChild); if (otherChildPrivate->subtreeHoverEnabled || otherChildPrivate->hoverEnabled) return; // nope! sorry, something else wants it kept on. - if (otherChildPrivate->hasHoverHandlers()) + if (otherChildPrivate->hasEnabledHoverHandlers()) return; // nope! sorry, we have pointer handlers which are interested. } } @@ -9011,12 +9011,12 @@ bool QQuickItemPrivate::hasPointerHandlers() const return extra.isAllocated() && !extra->pointerHandlers.isEmpty(); } -bool QQuickItemPrivate::hasHoverHandlers() const +bool QQuickItemPrivate::hasEnabledHoverHandlers() const { if (!hasPointerHandlers()) return false; for (QQuickPointerHandler *h : extra->pointerHandlers) - if (qmlobject_cast<QQuickHoverHandler *>(h)) + if (auto *hh = qmlobject_cast<QQuickHoverHandler *>(h); hh && hh->enabled()) return true; return false; } diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h index 4e5e5bb34a..5437aeb46c 100644 --- a/src/quick/items/qquickitem_p.h +++ b/src/quick/items/qquickitem_p.h @@ -248,7 +248,7 @@ public: void localizedTouchEvent(const QTouchEvent *event, bool isFiltering, QMutableTouchEvent *localized); bool hasPointerHandlers() const; - bool hasHoverHandlers() const; + bool hasEnabledHoverHandlers() const; virtual void addPointerHandler(QQuickPointerHandler *h); virtual void removePointerHandler(QQuickPointerHandler *h); |
