An application compiled with Qt 5.12.1 occasionally crashes when unplugging the external monitors from a MacBookPro running on macOS 10.14.3.
Steps to reproduce:
- I have a MacBookPro with a Thunderbolt Dock and 2 screens connected to the Dock.
- Run an application compiled with Qt 5.12.1
- Detach the Thunderbolt Dock from the MacBookPro
Result: The application sometimes crashes.
The crash occurs in QCocoaWindow::windowDidChangeScreen():
Note the call to the function screen() which can return a nullptr:
The QCocoaWindow::windowDidChangeScreen() function should check if screen() returns a nullptr pointer before using it. One possible fix would be to modify QCocoaWindow::windowDidChangeScreen() as follow: