[gnome-calendar] edit-dialog: fix memory leaks



commit 738bb89d94fc789293ce625e520c1ceefe822fbf
Author: Erick Pérez Castellanos <erick red gmail com>
Date:   Mon Dec 8 12:26:51 2014 -0500

    edit-dialog: fix memory leaks

 src/gcal-edit-dialog.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/src/gcal-edit-dialog.c b/src/gcal-edit-dialog.c
index e8da6db..1902de9 100644
--- a/src/gcal-edit-dialog.c
+++ b/src/gcal-edit-dialog.c
@@ -130,16 +130,18 @@ fill_sources_menu (GcalEditDialog *dialog)
       GMenuItem *item;
       ESourceSelectable *extension;
       GdkRGBA color;
+      GdkPixbuf *pix;
 
       source = E_SOURCE (aux->data);
 
       /* retrieve color */
       extension = E_SOURCE_SELECTABLE (e_source_get_extension (source, E_SOURCE_EXTENSION_CALENDAR));
       gdk_rgba_parse (&color, e_source_selectable_get_color (E_SOURCE_SELECTABLE (extension)));
+      pix = gcal_get_pixbuf_from_color (&color, 16);;
 
       /* menu item */
       item = g_menu_item_new (e_source_get_display_name (source), "edit.select_calendar");
-      g_menu_item_set_icon (item, G_ICON (gcal_get_pixbuf_from_color (&color, 16)));
+      g_menu_item_set_icon (item, G_ICON (pix));
 
       /* set insensitive for read-only calendars */
       if (gcal_manager_is_client_writable (priv->manager, source))
@@ -149,10 +151,13 @@ fill_sources_menu (GcalEditDialog *dialog)
       else
         {
           g_menu_item_set_action_and_target_value (item, "edit.select_calendar",
-                                                   g_variant_new_string (e_source_dup_uid (source)));
+                                                   g_variant_new_string (e_source_get_uid (source)));
         }
 
       g_menu_append_item (priv->sources_menu, item);
+
+      g_object_unref (pix);
+      g_object_unref (item);
     }
 
   gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (priv->sources_button), G_MENU_MODEL (priv->sources_menu));
@@ -186,13 +191,15 @@ on_calendar_selected (GtkWidget *menu_item,
       {
         GdkRGBA color;
         ESourceSelectable *extension;
+        GdkPixbuf *pix;
 
         /* retrieve color */
         extension = E_SOURCE_SELECTABLE (e_source_get_extension (source, E_SOURCE_EXTENSION_CALENDAR));
         gdk_rgba_parse (&color, e_source_selectable_get_color (E_SOURCE_SELECTABLE (extension)));
 
-        gtk_image_set_from_pixbuf (GTK_IMAGE (priv->source_image),
-                                   gcal_get_pixbuf_from_color (&color, 16));
+        pix = gcal_get_pixbuf_from_color (&color, 16);
+        gtk_image_set_from_pixbuf (GTK_IMAGE (priv->source_image), pix);
+        g_object_unref (pix);
 
         priv->source = source;
         gtk_header_bar_set_subtitle (GTK_HEADER_BAR (priv->titlebar),


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