[gnome-flashback] display-config: handle invalid previous configurations



commit 67d7aa3cf56c0642b09a4016222b06c34cbac76d
Author: Rui Matos <tiagomatos gmail com>
Date:   Tue Mar 29 21:56:28 2016 +0200

    display-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

 .../libdisplay-config/flashback-monitor-config.c   |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/gnome-flashback/libdisplay-config/flashback-monitor-config.c 
b/gnome-flashback/libdisplay-config/flashback-monitor-config.c
index f5faa1a..4886188 100644
--- a/gnome-flashback/libdisplay-config/flashback-monitor-config.c
+++ b/gnome-flashback/libdisplay-config/flashback-monitor-config.c
@@ -653,7 +653,11 @@ meta_monitor_config_assign_crtcs (MetaConfiguration       *config,
     }
 
   all_outputs = flashback_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++)
     {
@@ -2050,18 +2054,19 @@ flashback_monitor_config_restore_previous (FlashbackMonitorConfig *config)
       /* The user chose to restore the previous configuration. In this
        * case, restore the previous configuration. */
       MetaConfiguration *prev_config = config_ref (config->previous);
-      apply_configuration (config, prev_config);
+      gboolean ok = apply_configuration (config, prev_config);
       config_unref (prev_config);
 
       /* After this, self->previous contains the rejected configuration.
        * Since it was rejected, nuke it. */
       g_clear_pointer (&config->previous, (GDestroyNotify) config_unref);
+
+      if (ok)
+        return;
     }
-  else
-    {
-      if (!flashback_monitor_config_apply_stored (config))
-        flashback_monitor_config_make_default (config);
-    }
+
+  if (!flashback_monitor_config_apply_stored (config))
+    flashback_monitor_config_make_default (config);
 }
 
 gboolean


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