From 2f8b268fd1af1d1b1eb80088c40ccd11a0a4adaf Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Sun, 15 Apr 2001 22:29:03 +0000 Subject: Do not ref both the box and the item; just connect to the item's "destroy" 2001-04-15 Federico Mena Quintero * gal/widgets/e-canvas-vbox.c (e_canvas_vbox_real_add_item): Do not ref both the box and the item; just connect to the item's "destroy" signal. (e_canvas_vbox_remove_item): Do not unref the box. (e_canvas_vbox_destroy): Disconnect from the items. svn path=/trunk/; revision=9335 --- widgets/misc/e-canvas-vbox.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/widgets/misc/e-canvas-vbox.c b/widgets/misc/e-canvas-vbox.c index 3eebc921c9..5879d4f672 100644 --- a/widgets/misc/e-canvas-vbox.c +++ b/widgets/misc/e-canvas-vbox.c @@ -172,12 +172,25 @@ e_canvas_vbox_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) } } +/* Used from g_list_foreach(); disconnects from an item's signals */ +static void +disconnect_item_cb (gpointer data, gpointer user_data) +{ + ECanvasVbox *vbox; + GnomeCanvasItem *item; + + vbox = E_CANVAS_VBOX (user_data); + + item = GNOME_CANVAS_ITEM (data); + gtk_signal_disconnect_by_data (GTK_OBJECT (item), vbox); +} + static void e_canvas_vbox_destroy (GtkObject *object) { ECanvasVbox *vbox = E_CANVAS_VBOX(object); - g_list_foreach(vbox->items, (GFunc) gtk_object_unref, NULL); + g_list_foreach(vbox->items, disconnect_item_cb, vbox); g_list_free(vbox->items); vbox->items = NULL; @@ -234,18 +247,14 @@ e_canvas_vbox_realize (GnomeCanvasItem *item) static void e_canvas_vbox_remove_item (GnomeCanvasItem *item, ECanvasVbox *vbox) { - if (!GTK_OBJECT_DESTROYED (vbox)) { + if (!GTK_OBJECT_DESTROYED (vbox)) vbox->items = g_list_remove(vbox->items, item); - gtk_object_unref(GTK_OBJECT(vbox)); - } } static void e_canvas_vbox_real_add_item(ECanvasVbox *e_canvas_vbox, GnomeCanvasItem *item) { e_canvas_vbox->items = g_list_append(e_canvas_vbox->items, item); - gtk_object_ref(GTK_OBJECT(item)); - gtk_object_ref(GTK_OBJECT(e_canvas_vbox)); gtk_signal_connect(GTK_OBJECT(item), "destroy", GTK_SIGNAL_FUNC(e_canvas_vbox_remove_item), e_canvas_vbox); if ( GTK_OBJECT_FLAGS( e_canvas_vbox ) & GNOME_CANVAS_ITEM_REALIZED ) { @@ -254,7 +263,6 @@ e_canvas_vbox_real_add_item(ECanvasVbox *e_canvas_vbox, GnomeCanvasItem *item) NULL); e_canvas_item_request_reflow(item); } - } static void -- cgit v1.2.3