From dae238cc5f003cb27d86a9b53553c3ff15370d86 Mon Sep 17 00:00:00 2001 From: Rui Matos Date: Fri, 25 Aug 2017 15:57:13 +0200 Subject: [PATCH] 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 file changed, 10 insertions(+), 1 deletion(-) diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c index 0940e1857..ab80a4043 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;