From 3fc532ba3c45bfd87b82f095668549de57bee818 Mon Sep 17 00:00:00 2001 From: Hans Petter Jansson Date: Tue, 4 May 2004 01:51:20 +0000 Subject: Do ref, unref in right order, so the same contact can be set twice without 2004-05-03 Hans Petter Jansson * gui/widgets/e-minicard.c (e_minicard_set_property): Do ref, unref in right order, so the same contact can be set twice without ill effects. (e_minicard_finalize): NULL pointers after unreffing their objects. svn path=/trunk/; revision=25775 --- addressbook/gui/widgets/e-minicard.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'addressbook/gui') diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c index e49b162fc1..bffe91e49e 100644 --- a/addressbook/gui/widgets/e-minicard.c +++ b/addressbook/gui/widgets/e-minicard.c @@ -288,6 +288,7 @@ e_minicard_set_property (GObject *object, guint prop_id, const GValue *value, G { GnomeCanvasItem *item; EMinicard *e_minicard; + EContact *contact; GList *l; item = GNOME_CANVAS_ITEM (object); @@ -338,11 +339,15 @@ e_minicard_set_property (GObject *object, guint prop_id, const GValue *value, G set_has_cursor (e_minicard, g_value_get_boolean (value)); break; case PROP_CONTACT: + contact = E_CONTACT (g_value_get_object (value)); + if (contact) + g_object_ref (contact); + if (e_minicard->contact) g_object_unref (e_minicard->contact); - e_minicard->contact = E_CONTACT(g_value_get_object (value)); - if (e_minicard->contact) - g_object_ref (e_minicard->contact); + + e_minicard->contact = contact; + remodel(e_minicard); e_canvas_item_request_reflow(item); e_minicard->changed = FALSE; @@ -425,11 +430,15 @@ e_minicard_finalize (GObject *object) e_minicard = E_MINICARD (object); - if (e_minicard->contact) + if (e_minicard->contact) { g_object_unref (e_minicard->contact); + e_minicard->contact = NULL; + } - if (e_minicard->list_icon_pixbuf) + if (e_minicard->list_icon_pixbuf) { g_object_unref (e_minicard->list_icon_pixbuf); + e_minicard->list_icon_pixbuf = NULL; + } if (G_OBJECT_CLASS (parent_class)->finalize) (* G_OBJECT_CLASS (parent_class)->finalize) (object); -- cgit v1.2.3