From 031e0f436404a08a10aad330aaf1b271e5cdc2e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 20 Apr 2017 14:06:35 +0200 Subject: [PATCH] macOS: Fix crash when closing windows with raster backingstore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After 5b78fcd03b6 the raster backingstore tries to use the platform window to resolve the native DPR, but we might not always have a platform window. Instead we go though the window, like before, which has fallback paths for the case of no platform window, and then remove the Qt scaling factor manually. Change-Id: I19c8383b0a33f3d97aaf0d0e886ed03e14cb1592 Reviewed-by: Morten Johan Sørvig --- src/platformsupport/graphics/qrasterbackingstore.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/platformsupport/graphics/qrasterbackingstore.cpp b/src/platformsupport/graphics/qrasterbackingstore.cpp index 2f7074403c..b8d393844c 100644 --- a/src/platformsupport/graphics/qrasterbackingstore.cpp +++ b/src/platformsupport/graphics/qrasterbackingstore.cpp @@ -60,7 +60,10 @@ void QRasterBackingStore::resize(const QSize &size, const QRegion &staticContent { Q_UNUSED(staticContents); - qreal nativeWindowDevicePixelRatio = window()->handle()->devicePixelRatio(); + // We can't guarantee that we have a platform-window at this point, so we have + // to pull out the DPR using QWindow and its QScreen fallback, and then remove + // the Qt scaling factor. + qreal nativeWindowDevicePixelRatio = window()->devicePixelRatio() / QHighDpiScaling::factor(window()); QSize effectiveBufferSize = size * nativeWindowDevicePixelRatio; if (m_image.size() == effectiveBufferSize)