[gnome-desktop] Only get the BACKLIGHT limits for connected outputs



commit 4eb1ef700cd6ec5bde07f3ef48a7b51dfe1b6319
Author: Richard Hughes <richard hughsie com>
Date:   Tue Jun 28 20:55:56 2011 +0100

    Only get the BACKLIGHT limits for connected outputs
    
    Otherwise XRRQueryOutputProperty crashes and burns.

 libgnome-desktop/gnome-rr.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/libgnome-desktop/gnome-rr.c b/libgnome-desktop/gnome-rr.c
index 5addd2a..a546967 100644
--- a/libgnome-desktop/gnome-rr.c
+++ b/libgnome-desktop/gnome-rr.c
@@ -1405,19 +1405,29 @@ static void
 update_brightness_limits (GnomeRROutput *output)
 {
 #ifdef HAVE_RANDR
+    gint rc;
     Atom atom;
     XRRPropertyInfo *info;
 
+    gdk_error_trap_push ();
     atom = XInternAtom (DISPLAY (output), "BACKLIGHT", FALSE);
     info = XRRQueryOutputProperty (DISPLAY (output), output->id, atom);
+    rc = gdk_error_trap_pop ();
+    if (rc != 0)
+    {
+        g_warning ("could not get output property for %s, rc: %i",
+		   output->name, rc);
+        goto out;
+    }
     if (info == NULL)
     {
-        g_warning ("could not get output property");
+        g_warning ("could not get output property for %s",
+		   output->name);
         goto out;
     }
     if (!info->range || info->num_values != 2)
     {
-        g_debug ("backlight was not range");
+        g_debug ("backlight %s was not range", output->name);
         goto out;
     }
     output->backlight_min = info->values[0];
@@ -1500,7 +1510,8 @@ output_initialize (GnomeRROutput *output, XRRScreenResources *res, GError **erro
     output->edid_data = read_edid_data (output, &output->edid_size);
 
     /* brightness data */
-    update_brightness_limits (output);
+    if (output->connected)
+        update_brightness_limits (output);
 
     XRRFreeOutputInfo (info);
 



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