/soc/2013/ankitkv/gobjectification: b1471cc401a4: Document the g...

Ankit Vani a at nevitus.org
Sun Jan 19 16:40:48 EST 2014


Changeset: b1471cc401a44c24ae32ec96c4e1dc775d980c15
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2014-01-20 02:00 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/b1471cc401a4

Description:

Document the g_object_unref before returning a plugin info or a plugin instance

diffstat:

 libpurple/plugins.c |  10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diffs (27 lines):

diff --git a/libpurple/plugins.c b/libpurple/plugins.c
--- a/libpurple/plugins.c
+++ b/libpurple/plugins.c
@@ -278,6 +278,11 @@ purple_plugin_get_info(const PurplePlugi
 	g_return_val_if_fail(plugin != NULL, NULL);
 
 	info = gplugin_plugin_get_info(plugin);
+
+	/* GPlugin refs the plugin info object before returning it. This workaround
+	 * is to avoid managing the reference counts everywhere in our codebase
+	 * where we would need the plugin info. The plugin info instance is
+	 * guaranteed to exist as long as the plugin exists. */
 	g_object_unref(info);
 
 	if (PURPLE_IS_PLUGIN_INFO(info))
@@ -994,6 +999,11 @@ purple_plugins_find_plugin(const gchar *
 	g_return_val_if_fail(id != NULL && *id != '\0', NULL);
 
 	plugin = gplugin_manager_find_plugin(id);
+
+	/* GPlugin refs the plugin object before returning it. This workaround is
+	 * to avoid managing the reference counts everywhere in our codebase where
+	 * we would need the plugin. The object is guaranteed to exist till the
+	 * plugins subsystem is uninitialized. */
 	g_object_unref(plugin);
 
 	return plugin;



More information about the Commits mailing list