QGuiApplication: fix misleading code
The comment says "don't send event if nothing changed", but the condition it is attached to reads if (velocityOnly), which is totally opaque. Change the variable name to stationaryTouchPointChangedVelocity and drop the then-branch of the if, because it is duplicated in the following default case of the switch. The comment makes sense again, and GCC 7 is happy, too, because this whole issue was pointed out by its -Wimplicit-fallthrough, which is why I added the fall-through attribute, too. Change-Id: I0631a381095f8897c55d9440304f6aefbc021a9a Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Sérgio Martins <sergio.martins@kdab.com>
This commit is contained in:
parent
940d667eb4
commit
9ba16336c5
@ -2472,7 +2472,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
|
|||||||
QWindow *window = e->window.data();
|
QWindow *window = e->window.data();
|
||||||
typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints;
|
typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints;
|
||||||
QHash<QWindow *, StatesAndTouchPoints> windowsNeedingEvents;
|
QHash<QWindow *, StatesAndTouchPoints> windowsNeedingEvents;
|
||||||
bool velocityOnly = false;
|
bool stationaryTouchPointChangedVelocity = false;
|
||||||
|
|
||||||
for (int i = 0; i < e->points.count(); ++i) {
|
for (int i = 0; i < e->points.count(); ++i) {
|
||||||
QTouchEvent::TouchPoint touchPoint = e->points.at(i);
|
QTouchEvent::TouchPoint touchPoint = e->points.at(i);
|
||||||
@ -2552,7 +2552,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
|
|||||||
if (touchPoint.state() == Qt::TouchPointStationary) {
|
if (touchPoint.state() == Qt::TouchPointStationary) {
|
||||||
if (touchInfo.touchPoint.velocity() != touchPoint.velocity()) {
|
if (touchInfo.touchPoint.velocity() != touchPoint.velocity()) {
|
||||||
touchInfo.touchPoint.setVelocity(touchPoint.velocity());
|
touchInfo.touchPoint.setVelocity(touchPoint.velocity());
|
||||||
velocityOnly = true;
|
stationaryTouchPointChangedVelocity = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
touchInfo.touchPoint = touchPoint;
|
touchInfo.touchPoint = touchPoint;
|
||||||
@ -2590,10 +2590,9 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
|
|||||||
break;
|
break;
|
||||||
case Qt::TouchPointStationary:
|
case Qt::TouchPointStationary:
|
||||||
// don't send the event if nothing changed
|
// don't send the event if nothing changed
|
||||||
if (velocityOnly)
|
if (!stationaryTouchPointChangedVelocity)
|
||||||
eventType = QEvent::TouchUpdate;
|
|
||||||
else
|
|
||||||
continue;
|
continue;
|
||||||
|
Q_FALLTHROUGH();
|
||||||
default:
|
default:
|
||||||
eventType = QEvent::TouchUpdate;
|
eventType = QEvent::TouchUpdate;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user