diff options
author | Tor Arne Vestbø <tor.arne.vestbo@digia.com> | 2015-01-20 16:20:29 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com> | 2015-02-02 16:19:06 +0000 |
commit | 3d4a2241b910811bead57ba1556227ab70385b7b (patch) | |
tree | 2991a1d099cc86903cc61f3ae7f556663244f10b | |
parent | 087c61f7b7ce3087f22e94437c10e7c48d5e570e (diff) |
iOS: Guard QIOSScreen against notifying Qt about changes to deleted QScreens
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 <richard.gustavsen@theqtcompany.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
-rw-r--r-- | src/plugins/platforms/ios/qiosscreen.mm | 20 |
1 files changed, 14 insertions, 6 deletions
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 |