[gtk+/gtk-2-24] trayicon-x11: Fix warnings when visual is not available.



commit 55e1b27c6fe5059369bdf50c2607708b03bdbc94
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Aug 30 14:31:00 2011 -0400

    trayicon-x11: Fix warnings when visual is not available.
    
    This fixes a regression introduced in commit
    b1a1685a33eca16979e63d79915395af0b36. gdk_visual_get_*_pixel_details()
    should not be called with a NULL visual.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=649588

 gtk/gtktrayicon-x11.c |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtktrayicon-x11.c b/gtk/gtktrayicon-x11.c
index 8e7f7cb..8767dc4 100644
--- a/gtk/gtktrayicon-x11.c
+++ b/gtk/gtktrayicon-x11.c
@@ -336,7 +336,6 @@ gtk_tray_icon_get_visual_property (GtkTrayIcon *icon)
   gulong nitems;
   gulong bytes_after;
   int error, result;
-  GdkVisual *visual;
 
   g_assert (icon->priv->manager_window != None);
 
@@ -351,18 +350,25 @@ gtk_tray_icon_get_visual_property (GtkTrayIcon *icon)
 			       &bytes_after, &(prop.prop_ch));
   error = gdk_error_trap_pop ();
 
-  visual = NULL;
-
   if (!error && result == Success &&
       type == XA_VISUALID && nitems == 1 && format == 32)
     {
-      VisualID visual_id = prop.prop[0];
+      VisualID visual_id;
+      GdkVisual *visual;
+
+      visual_id = prop.prop[0];
       visual = gdk_x11_screen_lookup_visual (screen, visual_id);
+
+      icon->priv->manager_visual = visual;
+      icon->priv->manager_visual_rgba = visual != NULL &&
+        (visual->red_prec + visual->blue_prec + visual->green_prec < visual->depth);
+    }
+  else
+    {
+      icon->priv->manager_visual = NULL;
+      icon->priv->manager_visual_rgba = FALSE;
     }
 
-  icon->priv->manager_visual = visual;
-  icon->priv->manager_visual_rgba = visual != NULL &&
-    (visual->red_prec + visual->blue_prec + visual->green_prec < visual->depth);
 
   /* For the background-relative hack we use when we aren't using a real RGBA
    * visual, we can't be double-buffered */



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