qnsview_mouse, scrollWheel: do not assume zero deltas on Ending phase

It's somewhat difficult to reproduce, but having a mac with a trackpad
and a huge scrollview (meaning I have to scroll fast and a lot), I am
able from time to time to trigger an assert on the line:
Q_ASSERT(pixelDelta.isNull() && angleDelta.isNull())

In all such cases, I can see that deltas are not zero, but equal
to the ones that the next event (momentumPhase == Begin) has.

The code is based on Tor Arne's patch.

Pick-to: 6.2 5.15
Fixes: QTBUG-97945
Change-Id: I874c776b265d3950cc2b6c1d8054363b3d0d1fde
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Timur Pocheptsov 2021-11-03 17:09:46 +01:00
parent efc1cd5799
commit 122f7d7adc

View File

@ -714,11 +714,11 @@ static const QPointingDevice *pointingDeviceFor(qint64 deviceID)
// had time to emit a momentum phase event.
if ([NSApp nextEventMatchingMask:NSEventMaskScrollWheel untilDate:[NSDate distantPast]
inMode:@"QtMomementumEventSearchMode" dequeue:NO].momentumPhase == NSEventPhaseBegan) {
Q_ASSERT(pixelDelta.isNull() && angleDelta.isNull());
return; // Ignore this event, as it has a delta of 0,0
return; // Ignore, even if it has delta
} else {
phase = Qt::ScrollEnd;
m_scrolling = false;
}
phase = Qt::ScrollEnd;
m_scrolling = false;
} else if (theEvent.momentumPhase == NSEventPhaseBegan) {
Q_ASSERT(!pixelDelta.isNull() && !angleDelta.isNull());
phase = Qt::ScrollUpdate; // Send as update, it has a delta