Fix division by zero crash when restoring screen settings
The restoredScreenNumber was used before it's existence was checked, which caused 'division by zero' if the screen has been removed after storing the screen number. The check if restoredScreenNumber exists was moved to happen before restoredScreenNumber is used for the first time. Change-Id: Iada0e8c5cbb6d8ca88df171dbee045be249f50cd Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
This commit is contained in:
parent
6ef5ca2e2f
commit
86601fc575
@ -7315,6 +7315,8 @@ bool QWidget::restoreGeometry(const QByteArray &geometry)
|
||||
stream >> restoredScreenWidth;
|
||||
|
||||
const QDesktopWidget * const desktop = QApplication::desktop();
|
||||
if (restoredScreenNumber >= desktop->numScreens())
|
||||
restoredScreenNumber = desktop->primaryScreen();
|
||||
const qreal screenWidthF = qreal(desktop->screenGeometry(restoredScreenNumber).width());
|
||||
// Sanity check bailing out when large variations of screen sizes occur due to
|
||||
// high DPI scaling or different levels of DPI awareness.
|
||||
@ -7342,9 +7344,6 @@ bool QWidget::restoreGeometry(const QByteArray &geometry)
|
||||
.expandedTo(d_func()->adjustedSize()));
|
||||
}
|
||||
|
||||
if (restoredScreenNumber >= desktop->numScreens())
|
||||
restoredScreenNumber = desktop->primaryScreen();
|
||||
|
||||
const QRect availableGeometry = desktop->availableGeometry(restoredScreenNumber);
|
||||
|
||||
// Modify the restored geometry if we are about to restore to coordinates
|
||||
|
Loading…
Reference in New Issue
Block a user