瀏覽代碼

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 2 年之前
父節點
當前提交
dfbc2839b4
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp

+ 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_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);