From 3d4a2241b910811bead57ba1556227ab70385b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 20 Jan 2015 16:20:29 +0100 Subject: iOS: Guard QIOSScreen against notifying Qt about changes to deleted QScreens MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that we can rely on screen() returning 0 when the QScreen is not available we can return early from updateProperties(). We still compute the member variables as they may be accessed directly for the still alive QPlatformScreen. Change-Id: Ia7d0d29a6b50a9c932b565dc53b23d66331c275e Reviewed-by: Richard Moe Gustavsen Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiosscreen.mm | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm index 68266de5ee..830b42a3f1 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -255,7 +255,19 @@ void QIOSScreen::updateProperties() } } - if (screen() && screen()->orientation() != orientation()) + if (m_geometry != previousGeometry) { + const qreal millimetersPerInch = 25.4; + m_physicalSize = QSizeF(m_geometry.size()) / m_unscaledDpi * millimetersPerInch; + } + + // At construction time, we don't yet have an associated QScreen, but we still want + // to compute the properties above so they are ready for when the QScreen attaches. + // Also, at destruction time the QScreen has already been torn down, so notifying + // Qt about changes to the screen will cause asserts in the event delivery system. + if (!screen()) + return; + + if (screen()->orientation() != orientation()) QWindowSystemInterface::handleScreenOrientationChange(screen(), orientation()); // Note: The screen orientation change and the geometry changes are not atomic, so when @@ -263,12 +275,8 @@ void QIOSScreen::updateProperties() // API yet. But conceptually it makes sense that the orientation update happens first, // and the geometry updates caused by auto-rotation happen after that. - if (m_geometry != previousGeometry || m_availableGeometry != previousAvailableGeometry) { - const qreal millimetersPerInch = 25.4; - m_physicalSize = QSizeF(m_geometry.size()) / m_unscaledDpi * millimetersPerInch; - + if (m_geometry != previousGeometry || m_availableGeometry != previousAvailableGeometry) QWindowSystemInterface::handleScreenGeometryChange(screen(), m_geometry, m_availableGeometry); - } } QRect QIOSScreen::geometry() const -- cgit v1.2.3