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>
This commit is contained in:
parent
087c61f7b7
commit
3d4a2241b9
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user