[gnome-desktop] GnomeRRConfig: try again when failing application because of access denied



commit dc85c78445c3f543bf1a91cb0e7e69ef7db3a817
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Sat Aug 17 17:54:45 2013 +0200

    GnomeRRConfig: try again when failing application because of access denied
    
    If we get an error due to stale configuration information, try
    again a second time after refreshing the screen. This can happen
    when mutter is using the X11 backend, as that causes multiple events,
    so a single ApplyConfiguration() can increase the serial multiple
    times, and there is a race between when mutter gets the event
    (increasing the serial) and when we get it, asking for the new
    configuration.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=705510

 libgnome-desktop/gnome-rr-config.c |   50 ++++++++++++++++++++++++++++++++++-
 1 files changed, 48 insertions(+), 2 deletions(-)
---
diff --git a/libgnome-desktop/gnome-rr-config.c b/libgnome-desktop/gnome-rr-config.c
index 7d0eb65..184b7da 100644
--- a/libgnome-desktop/gnome-rr-config.c
+++ b/libgnome-desktop/gnome-rr-config.c
@@ -633,7 +633,30 @@ gnome_rr_config_apply (GnomeRRConfig *config,
                       GnomeRRScreen *screen,
                       GError       **error)
 {
-    return gnome_rr_config_apply_helper (config, screen, FALSE, error);
+    gboolean ok;
+    GError *local_error;
+
+    local_error = NULL;
+    ok = gnome_rr_config_apply_helper (config, screen, FALSE, &local_error);
+    if (!ok)
+    {
+        if (g_error_matches (local_error, G_DBUS_ERROR, G_DBUS_ERROR_ACCESS_DENIED))
+        {
+            /* Stale configuration, refresh and try again */
+            g_error_free (local_error);
+
+            if (!gnome_rr_screen_refresh (screen, error))
+                return FALSE;
+
+            return gnome_rr_config_apply_helper (config, screen, FALSE, error);
+        }
+        else
+        {
+            g_propagate_error (error, local_error);
+        }
+    }
+
+    return ok;
 }
 
 gboolean
@@ -641,7 +664,30 @@ gnome_rr_config_apply_persistent (GnomeRRConfig *config,
                                  GnomeRRScreen *screen,
                                  GError       **error)
 {
-    return gnome_rr_config_apply_helper (config, screen, TRUE, error);
+    gboolean ok;
+    GError *local_error;
+
+    local_error = NULL;
+    ok = gnome_rr_config_apply_helper (config, screen, TRUE, &local_error);
+    if (!ok)
+    {
+        if (g_error_matches (local_error, G_DBUS_ERROR, G_DBUS_ERROR_ACCESS_DENIED))
+        {
+            /* Stale configuration, refresh and try again */
+            g_error_free (local_error);
+
+            if (!gnome_rr_screen_refresh (screen, error))
+                return FALSE;
+
+            return gnome_rr_config_apply_helper (config, screen, TRUE, error);
+        }
+        else
+        {
+            g_propagate_error (error, local_error);
+        }
+    }
+
+    return ok;
 }
 
 /**


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