Fix crash when skipping oversized displays

This commit is contained in:
Daniel Dunderfelt
2026-07-13 22:48:41 +03:00
committed by Cameron Gutman
parent 2a1749e231
commit 191cd32bb7
+7 -5
View File
@@ -148,21 +148,18 @@ void SystemProperties::updateDecoderProperties(bool hasHardwareAcceleration, boo
QRect SystemProperties::getNativeResolution(int displayIndex)
{
// Returns default constructed QRect if out of bounds
Q_ASSERT(!monitorNativeResolutions.isEmpty());
return monitorNativeResolutions.value(displayIndex);
}
QRect SystemProperties::getSafeAreaResolution(int displayIndex)
{
// Returns default constructed QRect if out of bounds
Q_ASSERT(!monitorSafeAreaResolutions.isEmpty());
return monitorSafeAreaResolutions.value(displayIndex);
}
int SystemProperties::getRefreshRate(int displayIndex)
{
// Returns 0 if out of bounds
Q_ASSERT(!monitorRefreshRates.isEmpty());
return monitorRefreshRates.value(displayIndex);
}
@@ -228,6 +225,8 @@ void SystemProperties::refreshDisplays()
}
monitorNativeResolutions.clear();
monitorSafeAreaResolutions.clear();
monitorRefreshRates.clear();
SDL_DisplayMode bestMode;
for (int displayIndex = 0; displayIndex < SDL_GetNumVideoDisplays(); displayIndex++) {
@@ -236,8 +235,11 @@ void SystemProperties::refreshDisplays()
if (StreamUtils::getNativeDesktopMode(displayIndex, &desktopMode, &safeArea)) {
if (desktopMode.w <= 8192 && desktopMode.h <= 8192) {
monitorNativeResolutions.insert(displayIndex, QRect(0, 0, desktopMode.w, desktopMode.h));
monitorSafeAreaResolutions.insert(displayIndex, QRect(0, 0, safeArea.w, safeArea.h));
// Keep these lists compact because their QML consumers iterate until
// the first empty entry. Inserting by SDL display index is invalid if
// an earlier display was skipped (for example, a >8K virtual display).
monitorNativeResolutions.append(QRect(0, 0, desktopMode.w, desktopMode.h));
monitorSafeAreaResolutions.append(QRect(0, 0, safeArea.w, safeArea.h));
}
else {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,