From 8b200de35ab084a8d61eaa10e2c23bda531a6557 Mon Sep 17 00:00:00 2001 From: Rui Matos Date: Tue, 27 Oct 2015 15:24:58 +0100 Subject: [PATCH] monitor-manager-xrandr: Skip outputs with no modes If we can't find any valid modes for an output we need to unwind and skip the output because trying to use a modeless output later will crash us. https://bugzilla.gnome.org/show_bug.cgi?id=756796 --- src/backends/x11/meta-monitor-manager-xrandr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c index 0acb217a8..f7e695df0 100644 --- a/src/backends/x11/meta-monitor-manager-xrandr.c +++ b/src/backends/x11/meta-monitor-manager-xrandr.c @@ -661,6 +661,8 @@ output_get_modes (MetaMonitorManager *manager, } } meta_output->n_modes = n_actual_modes; + if (n_actual_modes > 0) + meta_output->preferred_mode = meta_output->modes[0]; } static char * @@ -825,7 +827,6 @@ meta_monitor_manager_xrandr_read_current (MetaMonitorManager *manager) output_get_tile_info (manager_xrandr, meta_output); output_get_modes (manager, meta_output, output); - meta_output->preferred_mode = meta_output->modes[0]; meta_output->n_possible_crtcs = output->ncrtc; meta_output->possible_crtcs = g_new0 (MetaCRTC *, meta_output->n_possible_crtcs); @@ -873,7 +874,10 @@ meta_monitor_manager_xrandr_read_current (MetaMonitorManager *manager) else meta_output->backlight = -1; - n_actual_outputs++; + if (meta_output->n_modes == 0) + meta_monitor_manager_clear_output (meta_output); + else + n_actual_outputs++; } XRRFreeOutputInfo (output);