فهرست منبع

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