iOS: Don't crash on landscape mode startup
fromPortraitToPrimary is called from the QIOSScreen constructor. This is probably to early to call QGuiApplication functions. Change-Id: I882304fd641df13dc530491990245ba9ad495377 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
This commit is contained in:
parent
11d50be6dd
commit
c75bc5b532
@ -49,6 +49,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QPlatformScreen;
|
||||
|
||||
bool isQtApplication();
|
||||
QIOSViewController *rootViewController();
|
||||
|
||||
@ -58,7 +60,7 @@ CGPoint toCGPoint(const QPoint &point);
|
||||
QPoint fromCGPoint(const CGPoint &point);
|
||||
Qt::ScreenOrientation toQtScreenOrientation(UIDeviceOrientation uiDeviceOrientation);
|
||||
UIDeviceOrientation fromQtScreenOrientation(Qt::ScreenOrientation qtOrientation);
|
||||
QRect fromPortraitToPrimary(const QRect &rect);
|
||||
QRect fromPortraitToPrimary(const QRect &rect, QPlatformScreen *screen);
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
@ -131,11 +131,11 @@ UIDeviceOrientation fromQtScreenOrientation(Qt::ScreenOrientation qtOrientation)
|
||||
return uiOrientation;
|
||||
}
|
||||
|
||||
QRect fromPortraitToPrimary(const QRect &rect)
|
||||
QRect fromPortraitToPrimary(const QRect &rect, QPlatformScreen *screen)
|
||||
{
|
||||
// UIScreen is always in portrait. Use this function to convert CGRects
|
||||
// aligned with UIScreen into whatever is the current orientation of QScreen.
|
||||
QRect geometry = QGuiApplication::primaryScreen()->handle()->geometry();
|
||||
QRect geometry = screen->geometry();
|
||||
return geometry.width() < geometry.height() ? rect
|
||||
: QRect(rect.y(), geometry.width() - rect.width() - rect.x(), rect.height(), rect.width());
|
||||
}
|
||||
|
@ -83,7 +83,7 @@
|
||||
CGRect frame;
|
||||
[[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] getValue:&frame];
|
||||
|
||||
m_keyboardRect = fromPortraitToPrimary(fromCGRect(frame));
|
||||
m_keyboardRect = fromPortraitToPrimary(fromCGRect(frame), QGuiApplication::primaryScreen()->handle());
|
||||
m_context->emitKeyboardRectChanged();
|
||||
|
||||
BOOL visible = CGRectIntersectsRect(frame, [UIScreen mainScreen].bounds);
|
||||
|
@ -224,7 +224,7 @@ void QIOSScreen::setPrimaryOrientation(Qt::ScreenOrientation orientation)
|
||||
// Switching portrait/landscape means swapping width/height (and adjusting x/y):
|
||||
m_geometry = QRect(0, 0, m_geometry.height(), m_geometry.width());
|
||||
m_physicalSize = QSizeF(m_physicalSize.height(), m_physicalSize.width());
|
||||
m_availableGeometry = fromPortraitToPrimary(fromCGRect(m_uiScreen.applicationFrame));
|
||||
m_availableGeometry = fromPortraitToPrimary(fromCGRect(m_uiScreen.applicationFrame), this);
|
||||
|
||||
QWindowSystemInterface::handleScreenGeometryChange(screen(), m_geometry);
|
||||
QWindowSystemInterface::handleScreenAvailableGeometryChange(screen(), m_availableGeometry);
|
||||
|
Loading…
Reference in New Issue
Block a user