macOS: Handle NaN mouse event positions

When performing gestures such as Exposé or Mission Control with the
mouse button down, the position of the mouse release event is
returned with NaN values. This causes
QGuiApplicationPrivate::processMouseEvent to be called recursively
and ultimately crash.

Task-number: QTBUG-67194
Change-Id: If1536bc4dc2075c498cdd6c5afe57c86bdaac13b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Nathan Collins 2018-03-21 10:14:09 +00:00
parent 90ec3aba06
commit 992f673782
1 changed files with 6 additions and 2 deletions

View File

@ -487,8 +487,12 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
NSPoint screenPoint;
if (theEvent) {
NSPoint windowPoint = [theEvent locationInWindow];
NSRect screenRect = [[theEvent window] convertRectToScreen:NSMakeRect(windowPoint.x, windowPoint.y, 1, 1)];
screenPoint = screenRect.origin;
if (qIsNaN(windowPoint.x) || qIsNaN(windowPoint.y)) {
screenPoint = [NSEvent mouseLocation];
} else {
NSRect screenRect = [[theEvent window] convertRectToScreen:NSMakeRect(windowPoint.x, windowPoint.y, 1, 1)];
screenPoint = screenRect.origin;
}
} else {
screenPoint = [NSEvent mouseLocation];
}