diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index c8f6dd0..e236acc 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -388,14 +388,16 @@ void QCocoaIntegration::updateScreens() } siblings << screen; } + // All screens in mScreens are siblings because we ignored the mirrors. + // Update virtual siblings also for screens that are going to be deleted so that we are + // not using stale pointers when updating screens of windows. + foreach (QCocoaScreen* screen, mScreens) + screen->setVirtualSiblings(siblings); // Now the leftovers in remainingScreens are no longer current, so we can delete them. foreach (QCocoaScreen* screen, remainingScreens) { mScreens.removeOne(screen); destroyScreen(screen); } - // All screens in mScreens are siblings, because we ignored the mirrors. - foreach (QCocoaScreen* screen, mScreens) - screen->setVirtualSiblings(siblings); } QCocoaScreen *QCocoaIntegration::screenAtIndex(int index)