The current implementation found a QScreen by using the
position of the mouse in a call to QGuiApplication::screenAt().
From the documentation, this function is allowed to return
nullptr if the position is outside the screen.
From the stack track in the bug report, it seems very likely
that the mentioned call returns nullptr. This is strengthen
by the fact that the crash happens for messageboxes that are
maximized, so that you need to click on the upper corner of the
screen to close it. And then only when HiDPI scaling is in use
at the same time.
This patch will change the code to just use the screen that the
widget is on instead. If no screen can be resolved, the call will
default to primary screen.
Fixes: QTBUG-96639
Pick-to: 6.2
Change-Id: I31f0301318b358be9619caa31cc831b9598d5f90
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>