[gnome-control-center] display: Avoid crashing when a monitor doesn't have a mode set



commit dae238cc5f003cb27d86a9b53553c3ff15370d86
Author: Rui Matos <tiagomatos gmail com>
Date:   Fri Aug 25 15:57:13 2017 +0200

    display: Avoid crashing when a monitor doesn't have a mode set
    
    In this case just avoid showing information we don't have.

 panels/display/cc-display-panel.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c
index 0940e18..ab80a40 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -1082,7 +1082,7 @@ static gboolean
 should_show_scale_row (CcDisplayMonitor *output)
 {
   CcDisplayMode *mode = cc_display_monitor_get_mode (output);
-  return n_supported_scales (mode) > 1;
+  return mode ? n_supported_scales (mode) > 1 : FALSE;
 }
 
 static void
@@ -1130,6 +1130,9 @@ get_display_scales (CcDisplayMonitor *output,
   guint n, i, j;
 
   mode = cc_display_monitor_get_mode (output);
+  if (!mode)
+    return;
+
   all_scales = cc_display_mode_get_supported_scales (mode);
   n = n_supported_scales (mode);
   if (n <= MAX_N_SCALES)
@@ -3074,6 +3077,9 @@ get_resolution_string (CcDisplayMode *mode)
 {
   char *resolution;
 
+  if (!mode)
+    return "";
+
   resolution = g_object_get_data (G_OBJECT (mode), "resolution");
   if (resolution)
     return resolution;
@@ -3088,6 +3094,9 @@ get_frequency_string (CcDisplayMode *mode)
 {
   char *frequency;
 
+  if (!mode)
+    return "";
+
   frequency = g_object_get_data (G_OBJECT (mode), "frequency");
   if (frequency)
     return frequency;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]