Avoid QWindow crashing in mapToGlobal when no platformWindow
Add f60fb8f41741c2ca4dbd02b70d56e561be64d673 also to mapToGlobal. Amends 67fa2585ac48e64972d1c0a20b3add5c3ef72e51 Avoids crashing in certain applications that use QQuickRenderControl and QQuickWindows that are not backed by a QPlatformWindow. Change-Id: Ie4a8bd7837973e7997f9b668f776ca2999147d75 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
fa79b56bd8
commit
11e524d0cc
@ -2850,7 +2850,12 @@ QPointF QWindow::mapToGlobal(const QPointF &pos) const
|
||||
// Map the position (and the window's global position) to native coordinates, perform
|
||||
// the addition, and then map back to device independent coordinates.
|
||||
QPointF nativeLocalPos = QHighDpi::toNativeLocalPosition(pos, this);
|
||||
QPointF nativeWindowGlobalPos = d->platformWindow->mapToGlobal(QPoint(0,0)).toPointF();
|
||||
// Get the native window position directly from the platform window
|
||||
// if available (it can be null if the window hasn't been shown yet),
|
||||
// or fall back to scaling the QWindow position.
|
||||
QPointF nativeWindowGlobalPos = d->platformWindow
|
||||
? d->platformWindow->mapToGlobal(QPoint(0,0)).toPointF()
|
||||
: QHighDpi::toNativeGlobalPosition(QPointF(d->globalPosition()), this);
|
||||
QPointF nativeGlobalPos = nativeLocalPos + nativeWindowGlobalPos;
|
||||
QPointF deviceIndependentGlobalPos = QHighDpi::fromNativeGlobalPosition(nativeGlobalPos, this);
|
||||
return deviceIndependentGlobalPos;
|
||||
|
Loading…
x
Reference in New Issue
Block a user