/soc/2013/ankitkv/gobjectification: 42c3ae9b96d7: Better placed ...

Ankit Vani a at nevitus.org
Fri Aug 2 14:08:50 EDT 2013


Changeset: 42c3ae9b96d7b56b2f2d1b4a681383dd947fa997
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-08-02 23:38 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/42c3ae9b96d7

Description:

Better placed calls to gplugin_plugin_get_info() and its unref

diffstat:

 finch/gntconv.c    |   3 ++-
 finch/gntplugin.c  |  11 ++++++-----
 pidgin/gtkconv.c   |   3 ++-
 pidgin/gtkplugin.c |   3 +--
 4 files changed, 11 insertions(+), 9 deletions(-)

diffs (108 lines):

diff --git a/finch/gntconv.c b/finch/gntconv.c
--- a/finch/gntconv.c
+++ b/finch/gntconv.c
@@ -1253,10 +1253,11 @@ debug_command_cb(PurpleConversation *con
 			for (; plugins; plugins = plugins->next) {
 				GPluginPluginInfo *plugin_info = gplugin_plugin_get_info(plugins->data);
 				str = g_string_append(str, gplugin_plugin_info_get_name(plugin_info));
-				g_object_unref(plugin_info);
 
 				if (plugins->next)
 					str = g_string_append(str, ", ");
+
+				g_object_unref(plugin_info);
 			}
 		} else {
 			str = g_string_append(str, "(none)");
diff --git a/finch/gntplugin.c b/finch/gntplugin.c
--- a/finch/gntplugin.c
+++ b/finch/gntplugin.c
@@ -110,11 +110,12 @@ decide_conf_button(GPluginPlugin *plugin
 			visible = TRUE;
 		}
 	}
-	g_object_unref(info);
 
 	gnt_widget_set_visible(plugins.conf, visible);
 	gnt_box_readjust(GNT_BOX(plugins.window));
 	gnt_widget_draw(plugins.window);
+
+	g_object_unref(info);
 }
 
 static void
@@ -164,6 +165,8 @@ selection_changed(GntWidget *widget, gpo
 	if (!plugin)
 		return;
 
+	info = gplugin_plugin_get_info(plugin);
+
 	/* If the selected plugin was unseen before, mark it as seen. But save the list
 	 * only when the plugin list is closed. So if the user enables a plugin, and it
 	 * crashes, it won't get marked as seen so the user can fix the bug and still
@@ -178,8 +181,6 @@ selection_changed(GntWidget *widget, gpo
 		g_object_set_data(G_OBJECT(widget), "seen-list", list);
 	}
 
-	info = gplugin_plugin_get_info(plugin);
-
 	/* XXX: Use formatting and stuff */
 	gnt_text_view_clear(GNT_TEXT_VIEW(plugins.aboot));
 	text = g_strdup_printf(_("Name: %s\nVersion: %s\nDescription: %s\nAuthor: %s\nWebsite: %s\nFilename: %s\n"),
@@ -190,13 +191,13 @@ selection_changed(GntWidget *widget, gpo
 			SAFE(_(gplugin_plugin_info_get_website(info))),
 			SAFE(gplugin_plugin_get_filename(plugin)));
 
-	g_object_unref(info);
-
 	gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(plugins.aboot),
 			text, GNT_TEXT_FLAG_NORMAL);
 	gnt_text_view_scroll(GNT_TEXT_VIEW(plugins.aboot), 0);
 	g_free(text);
 	decide_conf_button(plugin);
+
+	g_object_unref(info);
 }
 
 static void
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -387,10 +387,11 @@ debug_command_cb(PurpleConversation *con
 			for (; plugins; plugins = plugins->next) {
 				GPluginPluginInfo *info = gplugin_plugin_get_info(GPLUGIN_PLUGIN(plugins->data));
 				str = g_string_append(str, gplugin_plugin_info_get_name(info));
-				g_object_unref(info);
 
 				if (plugins->next)
 					str = g_string_append(str, ", ");
+
+				g_object_unref(info);
 			}
 		} else {
 			str = g_string_append(str, "(none)");
diff --git a/pidgin/gtkplugin.c b/pidgin/gtkplugin.c
--- a/pidgin/gtkplugin.c
+++ b/pidgin/gtkplugin.c
@@ -414,12 +414,12 @@ static void plugin_toggled_stage_two(GPl
 		g_free(error);
 		g_free(name);
 	}
-	g_object_unref(info);
 
 	gtk_list_store_set(GTK_LIST_STORE (model), iter,
 	                   0, purple_plugin_is_loaded(plug),
 	                   -1);
 	g_free(iter);
+	g_object_unref(info);
 
 	pidgin_plugins_save();
 }
@@ -522,7 +522,6 @@ static void prefs_plugin_sel (GtkTreeSel
 	g_idle_add(ensure_plugin_visible, sel);
 
 	g_value_unset(&val);
-
 	g_object_unref(info);
 }
 



More information about the Commits mailing list