From 8587f0e80d7da4e8133466571fe4c884293eb700 Mon Sep 17 00:00:00 2001 From: Rui Matos Date: Tue, 29 Mar 2016 21:56:28 +0200 Subject: [PATCH] monitor-config: Handle invalid previous configurations The previous configuration might not apply because the number of enabled outputs when trying to apply it might have changed. This isn't a bug so we shouldn't assert. Instead, we can handle it by falling back as we would if we didn't have a previous configuration to start with. https://bugzilla.gnome.org/show_bug.cgi?id=764286 --- src/backends/meta-monitor-config.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/backends/meta-monitor-config.c b/src/backends/meta-monitor-config.c index e6e3791aa..a934613f4 100644 --- a/src/backends/meta-monitor-config.c +++ b/src/backends/meta-monitor-config.c @@ -1554,18 +1554,19 @@ meta_monitor_config_restore_previous (MetaMonitorConfig *self, /* The user chose to restore the previous configuration. In this * case, restore the previous configuration. */ MetaConfiguration *prev_config = config_ref (self->previous); - apply_configuration (self, prev_config, manager); + gboolean ok = apply_configuration (self, prev_config, manager); config_unref (prev_config); /* After this, self->previous contains the rejected configuration. * Since it was rejected, nuke it. */ g_clear_pointer (&self->previous, (GDestroyNotify) config_unref); + + if (ok) + return; } - else - { - if (!meta_monitor_config_apply_stored (self, manager)) - meta_monitor_config_make_default (self, manager); - } + + if (!meta_monitor_config_apply_stored (self, manager)) + meta_monitor_config_make_default (self, manager); } static void @@ -2029,7 +2030,11 @@ meta_monitor_config_assign_crtcs (MetaConfiguration *config, all_outputs = meta_monitor_manager_get_outputs (manager, &n_outputs); - g_assert (n_outputs == config->n_outputs); + if (n_outputs != config->n_outputs) + { + g_hash_table_destroy (assignment.info); + return FALSE; + } for (i = 0; i < n_outputs; i++) {