-
Bug
-
Resolution: Done
-
P2: Important
-
5.13.1
-
macOS 10.15.1
Qt 5.13.1
Description
When you disable the 'Mirror Displays' checkbox on macOS, all running Qt applications are crashing. See attached video to see Qt Creator crashing.
Reproducibility
- This issue is reproducible with Qt 5.13.1 on macOS 10.15.1
Steps to reproduce
- Attach an external display to a Mac (tested with iMac and MacBook Pro). I used a Thunderbolt Dock and Display Port to connect the external display.
- Launch any Qt application on the external screen. For example Qt Creator.
- Open System Preferences > Displays > Arrangement
- Check "Mirror Displays" if it is not checked
- Uncheck "Mirror Displays"
Result: All running Qt applications (for example Qt Creator) are crashing
Qt Support has tested and confirms the crash.
More info
The crash occurs in QCocoaScreen::initializeScreens() in qcocoascreen.mm.
As you can see in this code, there is no check for NULL pointer for the variable mainDisplay and cocoaScreen:
// Detect changes to the primary screen immediately, instead of
// waiting for a display reconfigure with kCGDisplaySetMainFlag.
// This ensures that any property updates to the other screens
// will be in reference to the correct primary screen.
QCocoaScreen *mainDisplay = QCocoaScreen::get(CGMainDisplayID());
if (QGuiApplication::primaryScreen()->handle() != mainDisplay) {
mainDisplay->updateProperties();
qCInfo(lcQpaScreen) << "Primary screen changed to" << mainDisplay;
QWindowSystemInterface::handlePrimaryScreenChanged(mainDisplay);
}
if (cocoaScreen == mainDisplay)
return; // Already reconfigured
cocoaScreen->updateProperties();
qCInfo(lcQpaScreen) << "Reconfigured" << cocoaScreen;
If the variables mainDisplay or cocoaScreen are NULL - which is what seems to be the case when disabling "Mirror Displays" - the application is crashing.