1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 20:28:11 +00:00

DisplaySettings: Handle case where there is no DPI value

DisplaySettings uses the optional `screen_dpi` value before checking
if it is set, causing an assertion failure. This change moves the
usage into the block where it is known to be set.

One situation where this is known to occur is on real hardware when
using the MULTIBOOT_VIDEO_MODE multiboot flag to enable graphical
display output.
This commit is contained in:
Edwin Rijkee 2023-07-27 16:26:34 +02:00 committed by Tim Flynn
parent bd7bd1d677
commit dfbc2839b4

View file

@ -214,10 +214,10 @@ ErrorOr<void> MonitorSettingsWidget::selected_screen_index_or_resolution_changed
}
}
auto dpi_label_value = String::formatted("{} dpi", screen_dpi.value());
if (screen_dpi.has_value() && !dpi_label_value.is_error()) {
if (screen_dpi.has_value()) {
auto dpi_label_value = TRY(String::formatted("{} dpi", screen_dpi.value()));
m_dpi_label->set_tooltip(screen_dpi_tooltip.to_deprecated_string());
m_dpi_label->set_text(dpi_label_value.release_value());
m_dpi_label->set_text(move(dpi_label_value));
m_dpi_label->set_visible(true);
} else {
m_dpi_label->set_visible(false);