From a11c776c444c0be1fd33276fc7ed4bef4494068c Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 7 Oct 2020 12:56:49 +0200 Subject: QApplicationPrivate: iterate QPointingDevPrv::activePoints values only In translateTouchCancel() and findClosestTouchPointTarget(), in the context of doing a range-for loop over activePoints: for (const auto &pair : devPriv->activePoints) { ... } clang was warning that the reference to the pair is a copy: warning: loop variable 'pair' is always a copy because the range of type 'QPointingDevicePrivate::EventPointMap' (aka 'QFlatMap') does not return a reference [-Wrange-loop-analysis] But we weren't using the key anyway, so we might as well iterate over values() just as various functions in QPointingDevicePrivate are doing. Change-Id: Id8ee784255af98064e8347d5fa6a806d442933a8 Reviewed-by: Joerg Bornemann --- src/widgets/kernel/qapplication.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/widgets/kernel/qapplication.cpp') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index c19fa2cd66..fdfb54881a 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3914,8 +3914,8 @@ QWidget *QApplicationPrivate::findClosestTouchPointTarget(const QPointingDevice QObject *closestTarget = nullptr; qreal closestDistance = 0; const QPointingDevicePrivate *devPriv = QPointingDevicePrivate::get(device); - for (const auto &pair : devPriv->activePoints) { - const auto &pt = pair.second.eventPoint; + for (auto &epd : devPriv->activePoints.values()) { + const auto &pt = epd.eventPoint; if (pt.id() != touchPoint.id()) { qreal dx = globalPos.x() - pt.globalPosition().x(); qreal dy = globalPos.y() - pt.globalPosition().y(); @@ -4077,8 +4077,8 @@ void QApplicationPrivate::translateTouchCancel(const QPointingDevice *device, ul QSet widgetsNeedingCancel; const QPointingDevicePrivate *devPriv = QPointingDevicePrivate::get(device); - for (const auto &pair : devPriv->activePoints) { - const auto &pt = pair.second.eventPoint; + for (auto &epd : devPriv->activePoints.values()) { + const auto &pt = epd.eventPoint; QObject *target = static_cast(pt).target(); if (target && target->isWidgetType()) widgetsNeedingCancel.insert(static_cast(target)); -- cgit v1.2.3