[macOS] Check that the screen's index is still valid after updating
It is possible for a screen to be disconnected while it is doing an update of the available screens. Therefore before returning the pointer to the screen then it should be rechecked that the index is still within the range of available screens. Change-Id: Iaa08070e79a72cb309d8a24cea786a5dccf6b719 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
This commit is contained in:
parent
14c6f80f4b
commit
deb2728a86
@ -450,6 +450,10 @@ QCocoaScreen *QCocoaIntegration::screenAtIndex(int index)
|
||||
if (index >= mScreens.count())
|
||||
updateScreens();
|
||||
|
||||
// It is possible that the screen got removed while updateScreens was called
|
||||
// so we do a sanity check to be certain
|
||||
if (index >= mScreens.count())
|
||||
return 0;
|
||||
return mScreens.at(index);
|
||||
}
|
||||
|
||||
|
@ -469,7 +469,8 @@ QT_WARNING_POP
|
||||
NSUInteger screenIndex = [[NSScreen screens] indexOfObject:self.window.screen];
|
||||
if (screenIndex != NSNotFound) {
|
||||
QCocoaScreen *cocoaScreen = QCocoaIntegration::instance()->screenAtIndex(screenIndex);
|
||||
QWindowSystemInterface::handleWindowScreenChanged(m_window, cocoaScreen->screen());
|
||||
if (cocoaScreen)
|
||||
QWindowSystemInterface::handleWindowScreenChanged(m_window, cocoaScreen->screen());
|
||||
m_platformWindow->updateExposedGeometry();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user