[Xfce4-commits] <xfce4-panel:master> Fix crash in systray with no children.

Nick Schermer noreply at xfce.org
Tue Nov 16 19:54:01 CET 2010


Updating branch refs/heads/master
         to 9d2fee8f33bf96fcd8d569f72f0205ac33c99eef (commit)
       from ce81b1199a9038c05586be7fee6c67ce1b1017e3 (commit)

commit 9d2fee8f33bf96fcd8d569f72f0205ac33c99eef
Author: Nick Schermer <nick at xfce.org>
Date:   Tue Nov 16 19:52:26 2010 +0100

    Fix crash in systray with no children.

 plugins/systray/systray-box.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/plugins/systray/systray-box.c b/plugins/systray/systray-box.c
index f8f478a..87ce03e 100644
--- a/plugins/systray/systray-box.c
+++ b/plugins/systray/systray-box.c
@@ -448,6 +448,7 @@ systray_box_size_allocate (GtkWidget     *widget,
   gint             child_size;
   GtkAllocation    child_allocation;
   gint             swap;
+  gint             n_children;
 
   panel_return_if_fail (XFCE_IS_SYSTRAY_BOX (widget));
   panel_return_if_fail (allocation != NULL);
@@ -455,6 +456,10 @@ systray_box_size_allocate (GtkWidget     *widget,
   /* set widget allocation */
   widget->allocation = *allocation;
 
+  n_children = g_slist_length (box->childeren);
+  if (n_children == 0)
+    return;
+
   /* get root coordinates */
   x = allocation->x + GTK_CONTAINER (widget)->border_width;
   y = allocation->y + GTK_CONTAINER (widget)->border_width;
@@ -469,9 +474,10 @@ systray_box_size_allocate (GtkWidget     *widget,
       child_size = IS_HORIZONTAL (box) ? width : height;
       if (box->n_hidden_childeren > 0)
          child_size -= BUTTON_SIZE + SPACING;
-      n = g_slist_length (box->childeren) - (box->show_hidden ? 0 : box->n_hidden_childeren);
+      n = n_children - (box->show_hidden ? 0 : box->n_hidden_childeren);
       child_size -= SPACING * MAX (n - 1, 0);
-      child_size /= n;
+      if (n > 1)
+        child_size /= n;
 
       if (IS_HORIZONTAL (box))
         y += MAX (height - child_size, 0) / 2;
@@ -493,8 +499,8 @@ systray_box_size_allocate (GtkWidget     *widget,
   if (box->n_hidden_childeren > 0)
     {
       /* initialize allocation */
-      child_allocation.x = x;
-      child_allocation.y = y;
+      child_allocation.x = allocation->x + GTK_CONTAINER (widget)->border_width;
+      child_allocation.y = allocation->y + GTK_CONTAINER (widget)->border_width;
 
       /* set the width and height */
       if (IS_HORIZONTAL (box))



More information about the Xfce4-commits mailing list