soc.2010.detachablepurple: 8de0a570: Updates the PurpleConstructor singleton ...

gillux at soc.pidgin.im gillux at soc.pidgin.im
Sun Aug 8 11:14:04 EDT 2010


----------------------------------------------------------------------
Revision: 8de0a5702d9532490588c4ff1d17bcdc2862eadc
Parent:   13f6b5fbc6649b6505aeffa0ba32368b71d7b6bd
Author:   gillux at soc.pidgin.im
Date:     08/06/10 13:58:52
Branch:   im.pidgin.soc.2010.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/8de0a5702d9532490588c4ff1d17bcdc2862eadc

Changelog: 

Updates the PurpleConstructor singleton system like the PurpleDBusCallback
one, now it's uninitialized on purple uninitialization.

Changes against parent 13f6b5fbc6649b6505aeffa0ba32368b71d7b6bd

  patched  libpurple/dbus/constructor.c
  patched  libpurple/dbus/constructor.h
  patched  libpurple/dbus-server.c

-------------- next part --------------
============================================================
--- libpurple/dbus-server.c	31b8441d043abaa2aaac3714925f4ab349460266
+++ libpurple/dbus-server.c	ff8062da5686163f8eaf331a59b5e54e2599be9d
@@ -826,7 +826,7 @@ purple_dbus_g_init(void)
 	purple_dbus_callback_do_init();
 
 	/* Instantiate and publish the PurpleConstructor */
-	purple_constructor_get_instance();
+	purple_constructor_do_init();
 }
 
 
@@ -1023,6 +1023,8 @@ purple_dbus_g_uninit(void)
 	g_hash_table_destroy(dbus_path_gobjects);
 	/* Destroy the PurpleDBusCallback. */
 	purple_dbus_callback_do_uninit();
+	/* Destroy the PurpleConstructor. */
+	purple_constructor_do_uninit();
 }
 
 void
============================================================
--- libpurple/dbus/constructor.c	c02fd0e6ac2212614c75bad8700712737eb2d1cd
+++ libpurple/dbus/constructor.c	6babbab3c176b88f0f992f8f9a1f0af5150f48b9
@@ -108,12 +108,34 @@ static void purple_constructor_class_ini
 	}
 }
 
-PurpleConstructor* purple_constructor_get_instance(void) {
-	static PurpleConstructor* self = NULL;
+void
+purple_constructor_do_init(void)
+{
+	purple_constructor_get_instance();
+}
+
+void
+purple_constructor_do_uninit(void)
+{
+	PurpleConstructorClass *klass;
+
+	klass = g_type_class_peek(PURPLE_TYPE_CONSTRUCTOR);
+	g_return_if_fail(klass->instance != NULL);
+	g_object_unref(klass->instance);
+}
+
+PurpleConstructor*
+purple_constructor_get_instance(void)
+{
 	DBusGProxy* proxy;
+	PurpleConstructorClass *klass;
+	PurpleConstructor *self;
 
-	if (self == NULL) {
+	klass = g_type_class_peek(PURPLE_TYPE_CONSTRUCTOR);
+	if (!klass) {
 		self = g_object_new(PURPLE_TYPE_CONSTRUCTOR, NULL);
+		klass = g_type_class_peek(PURPLE_TYPE_CONSTRUCTOR);
+		klass->instance = self;
 		purple_object_install_dbus_infos(
 					PURPLE_OBJECT(self),
 					DBUS_CONSTRUCTOR_INTERFACE,
@@ -129,7 +151,7 @@ PurpleConstructor* purple_constructor_ge
 									self, NULL);
 		}
 	}
-	return self;
+	return klass->instance;
 }
 
 gboolean
============================================================
--- libpurple/dbus/constructor.h	00ebc68d459b52bf971f3e66ee5f6df3ad215ead
+++ libpurple/dbus/constructor.h	d48449b34ce324647c343872741a0454b73b5cf5
@@ -32,12 +32,13 @@ typedef struct {
 GType purple_constructor_get_type(void);
 
 typedef struct {
-	PurpleObjectClass parent;
-} PurpleConstructorClass;
+	PurpleObject parent;
+} PurpleConstructor;
 
 typedef struct {
-	PurpleObject parent;
-} PurpleConstructor;
+	PurpleObjectClass parent;
+	PurpleConstructor* instance;
+} PurpleConstructorClass;
 
 /* DBus transfered data formats */
 
@@ -59,6 +60,19 @@ G_BEGIN_DECLS
 
 G_BEGIN_DECLS
 
+/**
+ * Creates the PurpleConstructor singleton.
+ */
+void purple_constructor_do_init(void);
+
+/**
+ * Destroys the PurpleConstructor singleton.
+ */
+void purple_constructor_do_uninit(void);
+
+/**
+ * Gets the PurpleConstructor singleton.
+ */
 PurpleConstructor* purple_constructor_get_instance(void);
 
 /**


More information about the Commits mailing list