macOS: Fix crash when closing windows with raster backingstore

After 5b78fcd03b 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 <morten.sorvig@qt.io>
This commit is contained in:
Tor Arne Vestbø 2017-04-20 14:06:35 +02:00
parent 4a46a7cf50
commit 031e0f4364

View File

@ -60,7 +60,10 @@ void QRasterBackingStore::resize(const QSize &size, const QRegion &staticContent
{ {
Q_UNUSED(staticContents); 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; QSize effectiveBufferSize = size * nativeWindowDevicePixelRatio;
if (m_image.size() == effectiveBufferSize) if (m_image.size() == effectiveBufferSize)