gobjectification: c4253bf5: Fixed a few more finalize issues

aluink at soc.pidgin.im aluink at soc.pidgin.im
Thu Jun 25 02:11:26 EDT 2009


-----------------------------------------------------------------
Revision: c4253bf5ddcc0ba68b4e1e24b3787dbb5bfc21da
Ancestor: 384c932971a5733966b387978e8303acaf0210cf
Author: aluink at soc.pidgin.im
Date: 2009-06-25T06:04:36
Branch: im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/c4253bf5ddcc0ba68b4e1e24b3787dbb5bfc21da

Modified files:
        libpurple/blist-node.c libpurple/blist.c libpurple/blist.h
        libpurple/buddy.c libpurple/chat.c libpurple/contact.c
        libpurple/group.c

ChangeLog: 

Fixed a few more finalize issues

-------------- next part --------------
============================================================
--- libpurple/blist-node.c	58c61b581f038045ae30ec3033caa68b7d6639e4
+++ libpurple/blist-node.c	a55977fb4417c186f0c2d19d975ca18c4a66d904
@@ -430,6 +430,7 @@ purple_blist_node_destroy(PurpleBlistNod
 void
 purple_blist_node_destroy(PurpleBlistNode *node)
 {
+  /* This function is only a hack for api breakage */
 	g_return_if_fail(PURPLE_IS_BLIST_NODE(node));
 	g_object_unref(G_OBJECT(node));
 }
============================================================
--- libpurple/blist.c	9a66ede74678fc25f37e51adc1cd091eb482ce88
+++ libpurple/blist.c	10e7e1e0a14cd94f1f9d246f8550ef1b83d82d95
@@ -41,6 +41,7 @@ PurpleBuddyList *purplebuddylist = NULL;
 static PurpleBlistUiOps *blist_ui_ops = NULL;
 
 PurpleBuddyList *purplebuddylist = NULL;
+static GObjectClass *parent_class = NULL;
 
 
 /*********************************************************************
@@ -312,12 +313,12 @@ PurpleBuddyList *purple_blist_new()
 {
 	PurpleBlistUiOps *ui_ops;
 	GList *account;
-	PurpleBuddyList *gbl = g_object_new(PURPLE_BLIST_TYPE, NULL);
+	PurpleBuddyList *gbl = g_object_new(PURPLE_BUDDY_LIST_TYPE, NULL);
 	PURPLE_DBUS_REGISTER_POINTER(gbl, PurpleBuddyList);
 
 	ui_ops = purple_blist_get_ui_ops();
 
-  #warning: This has to be set here or we can\'t add the buddies cache
+  #warning: This has to be set here or we cant add the buddies cache
   if(purplebuddylist) /* In case we're creating a replacement list */
     purple_blist_destroy();
   purple_set_blist(gbl);
@@ -383,12 +384,9 @@ void purple_blist_destroy()
 
 void purple_blist_destroy()
 {
-	PurpleBlistUiOps *ops = purple_blist_get_ui_ops();
-
-	purple_debug(PURPLE_DEBUG_INFO, "blist", "Destroying\n");
-
-	if (ops && ops->destroy)
-		ops->destroy(purplebuddylist);
+  /* This function is only a hack for api breakage */
+  g_return_if_fail(purplebuddylist != NULL);
+  g_object_unref(G_OBJECT(purplebuddylist));
 }
 
 void purple_blist_set_visible(gboolean show)
@@ -1238,9 +1236,26 @@ static void
 /******************/
 
 static void
+purple_blist_finalize(GObject *object)
+{
+  PurpleBuddyList *purplebuddylist = PURPLE_BUDDY_LIST(object);
+	PurpleBlistUiOps *ops = purple_blist_get_ui_ops();
+
+	purple_debug(PURPLE_DEBUG_INFO, "blist", "Destroying\n");
+
+	if (ops && ops->destroy)
+		ops->destroy(purplebuddylist);
+  parent_class->finalize(object);
+}
+
+static void
 purple_blist_class_init(PurpleBuddyListClass *klass)
 {
+	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
 
+	parent_class = g_type_class_peek_parent(klass);
+	obj_class->finalize = purple_blist_finalize;
+
 }
 
 static void
============================================================
--- libpurple/blist.h	0d9aef53101652de66001fb977897ba6d5dcc0ca
+++ libpurple/blist.h	5f470b36e09fe44795e394e2dc1db4fbac5eb390
@@ -124,12 +124,12 @@ typedef struct _PurpleBuddyListClass Pur
 /** @copydoc _PurpleBlist */
 typedef struct _PurpleBuddyList PurpleBuddyList;
 typedef struct _PurpleBuddyListClass PurpleBuddyListClass;
-#define PURPLE_BLIST_TYPE                  (purple_blist_get_gtype ())
-#define PURPLE_BLIST(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), PURPLE_BLIST_TYPE, PurpleBlist))
-#define PURPLE_IS_BLIST(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PURPLE_BLIST_TYPE))
-#define PURPLE_BLIST_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), PURPLE_BLIST_TYPE, PurpleBlistClass))
-#define PURPLE_IS_BLIST_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), PURPLE_BLIST_TYPE))
-#define PURPLE_GET_BLIST_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), PURPLE_BLIST_TYPE, PurpleBlistClass))
+#define PURPLE_BUDDY_LIST_TYPE                  (purple_blist_get_gtype ())
+#define PURPLE_BUDDY_LIST(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), PURPLE_BUDDY_LIST_TYPE, PurpleBuddyList))
+#define PURPLE_IS_BUDDY_LIST(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PURPLE_BUDDY_LIST_TYPE))
+#define PURPLE_BUDDY_LIST_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), PURPLE_BUDDY_LIST_TYPE, PurpleBuddyListClass))
+#define PURPLE_IS_BUDDY_LIST_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), PURPLE_BUDDY_LIST_TYPE))
+#define PURPLE_GET_BUDDY_LIST_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), PURPLE_BUDDY_LIST_TYPE, PurpleBuddyListClass))
 
 
 #include "account.h"
============================================================
--- libpurple/buddy.c	ffcb0c137bd59d9ce90a0ada19c238b9a2bf872b
+++ libpurple/buddy.c	de743f7f3cee9667dd2b93a33df681af5fd7119a
@@ -38,6 +38,8 @@
 #include "value.h"
 #include "xmlnode.h"
 
+static GObjectClass *parent_class = NULL;
+
 void
 parse_buddy(PurpleGroup *group, PurpleContact *contact, xmlnode *bnode)
 {
@@ -315,7 +317,7 @@ purple_buddy_destroy(PurpleBuddy *buddy)
 purple_buddy_destroy(PurpleBuddy *buddy)
 {
 	g_return_if_fail(PURPLE_IS_BUDDY(buddy));
-	g_object_unref(G_OBJECT(buddy));
+  g_object_unref(G_OBJECT(buddy));
 }
 
 void
@@ -540,8 +542,6 @@ buddy_to_xmlnode(PurpleBlistNode *bnode)
 /*  GObject Code  */
 /******************/
 
-static GObjectClass *parent_class = NULL;
-
 /* GObject destructor function */
 static void
 purple_buddy_finalize(GObject *object)
============================================================
--- libpurple/chat.c	1b9468151a2c401151193d5ed130d02e6824ab68
+++ libpurple/chat.c	8595dfb9c5997c5fedfede29389284799fdc9e0d
@@ -191,6 +191,7 @@ purple_chat_destroy(PurpleChat *chat)
 void
 purple_chat_destroy(PurpleChat *chat)
 {
+  /* This function is only a hack for api breakage */
 	g_return_if_fail(PURPLE_IS_CHAT(chat));
 	g_object_unref(G_OBJECT(chat));
 }
============================================================
--- libpurple/contact.c	44e39f3b210eaea218d0c442a2ec909fad68be68
+++ libpurple/contact.c	a8ae7dc696106f0e24928b9645bdf1afddf16fb7
@@ -216,7 +216,8 @@ purple_contact_destroy(PurpleContact *co
 void
 purple_contact_destroy(PurpleContact *contact)
 {
-	g_return_if_fail(PURPLE_IS_ACCOUNT(contact));
+  /* This function is only a hack for api breakage */
+	g_return_if_fail(PURPLE_IS_CONTACT(contact));
 	g_object_unref(G_OBJECT(contact));
 }
 
============================================================
--- libpurple/group.c	7b675abdf8d57b510cb2d3bd95d7384761de1c7e
+++ libpurple/group.c	9dc8d909ae3e494356bc245b70eec0340e56d16f
@@ -239,6 +239,7 @@ purple_group_destroy(PurpleGroup *group)
 void
 purple_group_destroy(PurpleGroup *group)
 {
+  /* This function is only a hack for api breakage */
   g_return_if_fail(PURPLE_IS_GROUP(group));
   g_object_unref(G_OBJECT(group));
 }


More information about the Commits mailing list