gobjectification: 0b146723: Add a 'destroyed' signal that emits afte...

sadrul at pidgin.im sadrul at pidgin.im
Tue Jul 13 18:04:00 EDT 2010


----------------------------------------------------------------------
Revision: 0b1467237f63ad3dc679b37162c1b1901a4a542e
Parent:   ef32576b34d995f4b3c7a88620aa273750290ca1
Author:   sadrul at pidgin.im
Date:     07/13/10 14:01:42
Branch:   im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/0b1467237f63ad3dc679b37162c1b1901a4a542e

Changelog: 

Add a 'destroyed' signal that emits after the object is completely destroyed.

Changes against parent ef32576b34d995f4b3c7a88620aa273750290ca1

  patched  libpurple/pobject.c

-------------- next part --------------
============================================================
--- libpurple/pobject.c	b92f13ab1f62397ba0fc6afc0e3a5ca3e8c592b4
+++ libpurple/pobject.c	3c9b16f252e48168902027d54502264883b62363
@@ -30,6 +30,7 @@ enum
 {
 	SIG_NEW,
 	SIG_DESTROYING,
+	SIG_DESTROYED,
 	SIG_LAST
 };
 
@@ -58,6 +59,13 @@ static void
 }
 
 static void
+purple_object_finalize(GObject *gobj)
+{
+	g_signal_emit(gobj, signals[SIG_DESTROYED], 0);
+	parent_class->finalize(gobj);
+}
+
+static void
 purple_object_class_init(PurpleObjectClass *klass)
 {
 	GObjectClass *gclass = G_OBJECT_CLASS(klass);
@@ -65,6 +73,7 @@ purple_object_class_init(PurpleObjectCla
 	parent_class = g_type_class_peek_parent(klass);
 
 	gclass->dispose = purple_object_dispose;
+	gclass->finalize = purple_object_finalize;
 
 	/* Signals */
 
@@ -80,6 +89,11 @@ purple_object_class_init(PurpleObjectCla
 				G_SIGNAL_ACTION, 0, NULL, NULL,
 				g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
 
+	/* This signal should be emitted when the object has been completely destroyed.
+	 * So the callback should not query the object for any information. */
+	signals[SIG_DESTROYED] = g_signal_new("destroyed", G_OBJECT_CLASS_TYPE(klass),
+				G_SIGNAL_ACTION, 0, NULL, NULL,
+				g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
 	g_type_class_add_private(klass, sizeof(PurpleObjectPrivate));
 }
 


More information about the Commits mailing list