From d3dc9fdeaf6dedab178c676150bd7b0a14ab8d0e Mon Sep 17 00:00:00 2001 From: Axel Spoerl Date: Mon, 7 Apr 2025 21:20:00 +0200 Subject: [PATCH] QGestureManager::deliverEvents() - improve debug output qDebug() why no target has been found for a gesture. Correct wrong function names in debug output. Use __FUNCTION__ macro instead of spelling function name out. Adapt QTest::ignoreMessage() calls in tst_gestures.cpp to also use the correct function name. Task-number: QTBUG-129754 Change-Id: Ifabf512215934ee984bcb8c9d0c2463342d77c07 Reviewed-by: David Faure --- src/widgets/kernel/qgesturemanager.cpp | 18 ++++++++++++------ tests/auto/other/gestures/tst_gestures.cpp | 8 ++++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index 558ad7c34ae..0ef01e824e1 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -606,6 +606,9 @@ void QGestureManager::deliverEvents(const QSet &gestures, if (gesture->hasHotSpot()) { // guess the target widget using the hotspot of the gesture QPoint pt = gesture->hotSpot().toPoint(); + qCDebug(lcGestureManager) << __FUNCTION__ << gesture + << "doesn't have a target yet." + << "Trying hotspot at" << pt; if (QWidget *topLevel = QApplication::topLevelAt(pt)) { QWidget *child = topLevel->childAt(topLevel->mapFromGlobal(pt)); target = child ? child : topLevel; @@ -615,6 +618,9 @@ void QGestureManager::deliverEvents(const QSet &gestures, QObject *context = m_gestureOwners.value(gesture, 0); if (context->isWidgetType()) target = static_cast(context); + qCDebug(lcGestureManager) << __FUNCTION__ << gesture + << "doesn't have a target yet." + << "Trying context" << context; } if (target) m_gestureTargets.insert(gesture, target); @@ -625,9 +631,9 @@ void QGestureManager::deliverEvents(const QSet &gestures, Q_UNUSED(gestureType); if (Q_UNLIKELY(!target)) { - qCDebug(lcGestureManager) << "QGestureManager::deliverEvent: could not find the target for gesture" + qCDebug(lcGestureManager) << __FUNCTION__ << "could not find the target for gesture" << gesture->gestureType(); - qWarning("QGestureManager::deliverEvent: could not find the target for gesture"); + qWarning("QGestureManager::deliverEvents: could not find the target for gesture"); undeliveredGestures->insert(gesture); } else { if (gesture->state() == Qt::GestureStarted) { @@ -639,7 +645,7 @@ void QGestureManager::deliverEvents(const QSet &gestures, } getGestureTargets(startedGestures, &conflictedGestures, &normalStartedGestures); - qCDebug(lcGestureManager) << "QGestureManager::deliverEvents:" + qCDebug(lcGestureManager) << __FUNCTION__ << "\nstarted: " << startedGestures << "\nconflicted: " << conflictedGestures << "\nnormal: " << normalStartedGestures @@ -650,7 +656,7 @@ void QGestureManager::deliverEvents(const QSet &gestures, e = conflictedGestures.constEnd(); it != e; ++it) { QWidget *receiver = it.key(); const QList &gestures = it.value(); - qCDebug(lcGestureManager) << "QGestureManager::deliverEvents: sending GestureOverride to" + qCDebug(lcGestureManager) << __FUNCTION__ << "sending GestureOverride to" << receiver << "gestures:" << gestures; QGestureEvent event(gestures); @@ -684,8 +690,8 @@ void QGestureManager::deliverEvents(const QSet &gestures, for (GesturesPerWidget::const_iterator it = normalStartedGestures.constBegin(), e = normalStartedGestures.constEnd(); it != e; ++it) { if (!it.value().isEmpty()) { - qCDebug(lcGestureManager) << "QGestureManager::deliverEvents: sending to" << it.key() - << "gestures:" << it.value(); + qCDebug(lcGestureManager) << __FUNCTION__ << "sending to" << it.key() + << "gestures:" << it.value(); QGestureEvent event(it.value()); QCoreApplication::sendEvent(it.key(), &event); bool eventAccepted = event.isAccepted(); diff --git a/tests/auto/other/gestures/tst_gestures.cpp b/tests/auto/other/gestures/tst_gestures.cpp index 1165fa48a36..91c2814cdd3 100644 --- a/tests/auto/other/gestures/tst_gestures.cpp +++ b/tests/auto/other/gestures/tst_gestures.cpp @@ -851,10 +851,10 @@ void tst_Gestures::graphicsItemGesture() CustomEvent event; // gesture without hotspot should not be delivered to items in the view - QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvent: could not find the target for gesture"); - QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvent: could not find the target for gesture"); - QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvent: could not find the target for gesture"); - QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvent: could not find the target for gesture"); + QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvents: could not find the target for gesture"); + QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvents: could not find the target for gesture"); + QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvents: could not find the target for gesture"); + QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvents: could not find the target for gesture"); sendCustomGesture(&event, item, &scene); QTRY_COMPARE(item->customEventsReceived, TotalCustomEventsCount);