Avoid QWindow crashing in mapToGlobal when no platformWindow
Addbb10f60fb8f417also to mapToGlobal. Amends67fa2585acAvoids 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>
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…
Reference in New Issue