Explorar o código

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.
Edwin Rijkee hai 1 ano
pai
achega
dfbc2839b4

+ 3 - 3
Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp

@@ -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_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);
         m_dpi_label->set_visible(true);
     } else {
     } else {
         m_dpi_label->set_visible(false);
         m_dpi_label->set_visible(false);