diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-02-01 07:56:23 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-02-22 14:48:38 +0100 |
commit | c5792dcfd631abb4f9e2b92cd6e88d7e5c373406 (patch) | |
tree | 83d79ff6b099fc211ba9267bf2d585a5b2044564 /src/widgets/kernel/qwidgetwindow.cpp | |
parent | 29a7489769bca59630782061789561fb07d77892 (diff) |
Make QGuiApplicationPrivate::lastCursorPosition.toPoint() safe to use
QGuiApplicationPrivate::lastCursorPosition is initialized with qInf();
so before Qt has seen a mouse move event, attempting to convert to
QPoint is an error. It's best to have one place where we do the qIsInf()
check rather than several (and otherwise prefer using the QPointF as-is
rather than converting to QPoint at all).
Introduce a helper class that contains a QPointF, and provides a safe
conversion to QPoint, as well as simple accessors for clients using
QPointF.
Fixes: QTBUG-52472
Task-number: QTBUG-45045
Change-Id: I83fad1bfb658e03fa876344552f1d5bb751d9f81
Pick-to: 6.2 6.3
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/widgets/kernel/qwidgetwindow.cpp')
-rw-r--r-- | src/widgets/kernel/qwidgetwindow.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 14a2655e35..88818ce9c5 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -402,7 +402,7 @@ void QWidgetWindow::handleEnterLeaveEvent(QEvent *event) QWindowSystemInterfacePrivate::EnterEvent *systemEvent = static_cast<QWindowSystemInterfacePrivate::EnterEvent *> (QWindowSystemInterfacePrivate::peekWindowSystemEvent(QWindowSystemInterfacePrivate::Enter)); - const QPointF globalPosF = systemEvent ? systemEvent->globalPos : QGuiApplicationPrivate::lastCursorPosition; + const QPointF globalPosF = systemEvent ? systemEvent->globalPos : QPointF(QGuiApplicationPrivate::lastCursorPosition); if (systemEvent) { if (QWidgetWindow *enterWindow = qobject_cast<QWidgetWindow *>(systemEvent->enter)) { |