[evolution] Fix few more memory leaks



commit 1ea0e626cb9306f9ec2204e1e0adb86ec86e692f
Author: Milan Crha <mcrha redhat com>
Date:   Fri Feb 21 14:43:41 2014 +0100

    Fix few more memory leaks

 composer/e-composer-private.c |   18 ++++++++----------
 e-util/e-name-selector-list.c |   20 ++++++++++++++++++++
 2 files changed, 28 insertions(+), 10 deletions(-)
---
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index 7a1b5a4..786faba 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -236,14 +236,14 @@ e_composer_private_constructed (EMsgComposer *composer)
 
        widget = e_activity_bar_new ();
        gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
-       priv->activity_bar = g_object_ref (widget);
+       priv->activity_bar = g_object_ref_sink (widget);
        /* EActivityBar controls its own visibility. */
 
        /* Construct the alert bar for errors. */
 
        widget = e_alert_bar_new ();
        gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
-       priv->alert_bar = g_object_ref (widget);
+       priv->alert_bar = g_object_ref_sink (widget);
        /* EAlertBar controls its own visibility. */
 
        /* Construct the header table. */
@@ -252,7 +252,7 @@ e_composer_private_constructed (EMsgComposer *composer)
        gtk_container_set_border_width (GTK_CONTAINER (widget), 6);
        gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
        gtk_box_reorder_child (GTK_BOX (container), widget, 2);
-       priv->header_table = g_object_ref (widget);
+       priv->header_table = g_object_ref_sink (widget);
        gtk_widget_show (widget);
 
        g_signal_connect (
@@ -263,7 +263,7 @@ e_composer_private_constructed (EMsgComposer *composer)
 
        widget = e_attachment_paned_new ();
        gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
-       priv->attachment_paned = g_object_ref (widget);
+       priv->attachment_paned = g_object_ref_sink (widget);
        gtk_widget_show (widget);
 
        g_object_bind_property (
@@ -288,7 +288,7 @@ e_composer_private_constructed (EMsgComposer *composer)
                GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
        gtk_widget_set_size_request (widget, -1, GALLERY_INITIAL_HEIGHT);
        gtk_paned_pack1 (GTK_PANED (container), widget, FALSE, FALSE);
-       priv->gallery_scrolled_window = g_object_ref (widget);
+       priv->gallery_scrolled_window = g_object_ref_sink (widget);
        gtk_widget_show (widget);
 
        /* Reparent the scrolled window containing the GtkHTML widget
@@ -307,7 +307,7 @@ e_composer_private_constructed (EMsgComposer *composer)
                settings, "composer-gallery-path");
        widget = e_picture_gallery_new (gallery_path);
        gtk_container_add (GTK_CONTAINER (container), widget);
-       priv->gallery_icon_view = g_object_ref (widget);
+       priv->gallery_icon_view = g_object_ref_sink (widget);
        g_free (gallery_path);
 
        g_signal_connect (
@@ -434,10 +434,8 @@ e_composer_private_dispose (EMsgComposer *composer)
                composer->priv->composer_actions = NULL;
        }
 
-       if (composer->priv->gallery_scrolled_window != NULL) {
-               g_object_unref (composer->priv->gallery_scrolled_window);
-               composer->priv->gallery_scrolled_window = NULL;
-       }
+       g_clear_object (&composer->priv->gallery_icon_view);
+       g_clear_object (&composer->priv->gallery_scrolled_window);
 
        g_hash_table_remove_all (composer->priv->inline_images);
        g_hash_table_remove_all (composer->priv->inline_images_by_url);
diff --git a/e-util/e-name-selector-list.c b/e-util/e-name-selector-list.c
index 19c20ed..f2d2a06 100644
--- a/e-util/e-name-selector-list.c
+++ b/e-util/e-name-selector-list.c
@@ -674,12 +674,32 @@ name_selector_list_realize (GtkWidget *widget)
 }
 
 static void
+name_selector_list_dispose (GObject *object)
+{
+       ENameSelectorList *list;
+
+       list = E_NAME_SELECTOR_LIST (object);
+
+       if (list->priv->popup) {
+               gtk_widget_destroy (GTK_WIDGET (list->priv->popup));
+               list->priv->popup = NULL;
+       }
+
+       /* Chain up to parent's method. */
+       G_OBJECT_CLASS (e_name_selector_list_parent_class)->dispose (object);
+}
+
+static void
 e_name_selector_list_class_init (ENameSelectorListClass *class)
 {
+       GObjectClass *object_class;
        GtkWidgetClass *widget_class;
 
        g_type_class_add_private (class, sizeof (ENameSelectorListPrivate));
 
+       object_class = G_OBJECT_CLASS (class);
+       object_class->dispose = name_selector_list_dispose;
+
        widget_class = GTK_WIDGET_CLASS (class);
        widget_class->realize = name_selector_list_realize;
 }


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