[libwnck] core: Plug a leak



commit 0ebc4fc1079a5c406840f43a36c30d4f721ddb8c
Author: Lampersperger Andreas <lampersperger andreas heidenhain de>
Date:   Thu Jan 20 16:56:12 2011 +0100

    core: Plug a leak

 libwnck/class-group.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/libwnck/class-group.c b/libwnck/class-group.c
index a636bed..0bcaf9e 100644
--- a/libwnck/class-group.c
+++ b/libwnck/class-group.c
@@ -413,6 +413,7 @@ static void
 set_icon (WnckClassGroup *class_group)
 {
   GdkPixbuf *icon, *mini_icon;
+  gboolean icons_reffed = FALSE;
 
   get_icons_from_applications (class_group, &icon, &mini_icon);
 
@@ -420,12 +421,15 @@ set_icon (WnckClassGroup *class_group)
     get_icons_from_windows (class_group, &icon, &mini_icon);
 
   if (!icon || !mini_icon)
+    {
       _wnck_get_fallback_icons (&icon,
                                 DEFAULT_ICON_WIDTH,
                                 DEFAULT_ICON_HEIGHT,
                                 &mini_icon,
                                 DEFAULT_MINI_ICON_WIDTH,
                                 DEFAULT_MINI_ICON_HEIGHT);
+      icons_reffed = TRUE;
+    }
 
   g_assert (icon && mini_icon);
 
@@ -435,8 +439,14 @@ set_icon (WnckClassGroup *class_group)
   if (class_group->priv->mini_icon)
     g_object_unref (class_group->priv->mini_icon);
 
-  class_group->priv->icon = g_object_ref (icon);
-  class_group->priv->mini_icon = g_object_ref (mini_icon);
+  class_group->priv->icon = icon;
+  class_group->priv->mini_icon = mini_icon;
+
+  if (!icons_reffed)
+    {
+      g_object_ref (class_group->priv->icon);
+      g_object_ref (class_group->priv->mini_icon);
+    }
 
   g_signal_emit (G_OBJECT (class_group), signals[ICON_CHANGED], 0);
 }



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