pidgin: 62dca91b: gtkblist: Fix a few memory leaks. Refs ...

rekkanoryo at pidgin.im rekkanoryo at pidgin.im
Wed Jan 5 11:32:07 EST 2011


----------------------------------------------------------------------
Revision: 62dca91b245f468607f6a3913abb28205511f869
Parent:   84be87a2114c41498d48d1c1d498840619a61346
Author:   morshed.nader at gmail.com
Date:     01/05/11 11:20:42
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/62dca91b245f468607f6a3913abb28205511f869

Changelog: 

gtkblist: Fix a few memory leaks.  Refs #13162.

Changes against parent 84be87a2114c41498d48d1c1d498840619a61346

  patched  pidgin/gtkblist.c

-------------- next part --------------
============================================================
--- pidgin/gtkblist.c	5d41aed9ca62bfc490a33dfcc4924bb2098149ee
+++ pidgin/gtkblist.c	6af89ce91a9b8d525df534bc6742642bb64fd1a4
@@ -418,16 +418,13 @@ static void gtk_blist_renderer_editing_s
 {
 	GtkTreeIter iter;
 	GtkTreePath *path = NULL;
-	GValue val;
 	PurpleBlistNode *node;
 	const char *text = NULL;
 
 	path = gtk_tree_path_new_from_string (path_str);
 	gtk_tree_model_get_iter (GTK_TREE_MODEL(gtkblist->treemodel), &iter, path);
 	gtk_tree_path_free (path);
-	val.g_type = 0;
-	gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val);
-	node = g_value_get_pointer(&val);
+	gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1);
 
 	switch (purple_blist_node_get_type(node)) {
 	case PURPLE_BLIST_CONTACT_NODE:
@@ -573,7 +570,6 @@ static void gtk_blist_renderer_edited_cb
 {
 	GtkTreeIter iter;
 	GtkTreePath *path;
-	GValue val;
 	PurpleBlistNode *node;
 	PurpleGroup *dest;
 
@@ -581,9 +577,7 @@ static void gtk_blist_renderer_edited_cb
 	path = gtk_tree_path_new_from_string (arg1);
 	gtk_tree_model_get_iter (GTK_TREE_MODEL(gtkblist->treemodel), &iter, path);
 	gtk_tree_path_free (path);
-	val.g_type = 0;
-	gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val);
-	node = g_value_get_pointer(&val);
+	gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1);
 	gtk_tree_view_set_enable_search (GTK_TREE_VIEW(gtkblist->treeview), TRUE);
 	g_object_set(G_OBJECT(gtkblist->text_rend), "editable", FALSE, NULL);
 
@@ -1160,13 +1154,9 @@ static void gtk_blist_row_expanded_cb(Gt
 static void gtk_blist_row_expanded_cb(GtkTreeView *tv, GtkTreeIter *iter, GtkTreePath *path, gpointer user_data)
 {
 	PurpleBlistNode *node;
-	GValue val;
 
-	val.g_type = 0;
-	gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), iter, NODE_COLUMN, &val);
+	gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), iter, NODE_COLUMN, &node, -1);
 
-	node = g_value_get_pointer(&val);
-
 	if (PURPLE_BLIST_NODE_IS_GROUP(node)) {
 		char *title;
 
@@ -1186,13 +1176,9 @@ static void gtk_blist_row_collapsed_cb(G
 static void gtk_blist_row_collapsed_cb(GtkTreeView *tv, GtkTreeIter *iter, GtkTreePath *path, gpointer user_data)
 {
 	PurpleBlistNode *node;
-	GValue val;
 
-	val.g_type = 0;
-	gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), iter, NODE_COLUMN, &val);
+	gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), iter, NODE_COLUMN, &node, -1);
 
-	node = g_value_get_pointer(&val);
-
 	if (PURPLE_BLIST_NODE_IS_GROUP(node)) {
 		char *title;
 		struct _pidgin_blist_node *gtknode;
@@ -1226,14 +1212,10 @@ static void gtk_blist_row_activated_cb(G
 static void gtk_blist_row_activated_cb(GtkTreeView *tv, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data) {
 	PurpleBlistNode *node;
 	GtkTreeIter iter;
-	GValue val;
 
 	gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path);
+	gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1);
 
-	val.g_type = 0;
-	gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val);
-	node = g_value_get_pointer(&val);
-
 	if(PURPLE_BLIST_NODE_IS_CONTACT(node) || PURPLE_BLIST_NODE_IS_BUDDY(node)) {
 		PurpleBuddy *buddy;
 
@@ -1595,7 +1577,6 @@ gtk_blist_key_press_cb(GtkWidget *tv, Gd
 gtk_blist_key_press_cb(GtkWidget *tv, GdkEventKey *event, gpointer data)
 {
 	PurpleBlistNode *node;
-	GValue val;
 	GtkTreeIter iter, parent;
 	GtkTreeSelection *sel;
 	GtkTreePath *path;
@@ -1604,10 +1585,7 @@ gtk_blist_key_press_cb(GtkWidget *tv, Gd
 	if(!gtk_tree_selection_get_selected(sel, NULL, &iter))
 		return FALSE;
 
-	val.g_type = 0;
-	gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), &iter,
-			NODE_COLUMN, &val);
-	node = g_value_get_pointer(&val);
+	gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1);
 
 	if(event->state & GDK_CONTROL_MASK &&
 			(event->keyval == 'o' || event->keyval == 'O')) {
@@ -1948,7 +1926,6 @@ gtk_blist_button_press_cb(GtkWidget *tv,
 {
 	GtkTreePath *path;
 	PurpleBlistNode *node;
-	GValue val;
 	GtkTreeIter iter;
 	GtkTreeSelection *sel;
 	PurplePlugin *prpl = NULL;
@@ -1960,9 +1937,7 @@ gtk_blist_button_press_cb(GtkWidget *tv,
 	if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), event->x, event->y, &path, NULL, NULL, NULL))
 		return FALSE;
 	gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path);
-	val.g_type = 0;
-	gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val);
-	node = g_value_get_pointer(&val);
+	gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1);
 	gtknode = (struct _pidgin_blist_node *)node->ui_data;
 
 	/* Right click draws a context menu */
@@ -2021,7 +1996,6 @@ pidgin_blist_popup_menu_cb(GtkWidget *tv
 pidgin_blist_popup_menu_cb(GtkWidget *tv, void *user_data)
 {
 	PurpleBlistNode *node;
-	GValue val;
 	GtkTreeIter iter;
 	GtkTreeSelection *sel;
 	gboolean handled = FALSE;
@@ -2030,10 +2004,7 @@ pidgin_blist_popup_menu_cb(GtkWidget *tv
 	if (!gtk_tree_selection_get_selected(sel, NULL, &iter))
 		return FALSE;
 
-	val.g_type = 0;
-	gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel),
-							 &iter, NODE_COLUMN, &val);
-	node = g_value_get_pointer(&val);
+	gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1);
 
 	/* Shift+F10 draws a context menu */
 	handled = pidgin_blist_show_context_menu(node, pidgin_treeview_popup_menu_position_func, tv, 0, GDK_CURRENT_TIME);
@@ -2274,13 +2245,10 @@ static void pidgin_blist_drag_data_get_c
 		GtkTreePath *sourcerow = gtk_tree_row_reference_get_path(ref);
 		GtkTreeIter iter;
 		PurpleBlistNode *node = NULL;
-		GValue val;
 		if(!sourcerow)
 			return;
 		gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, sourcerow);
-		val.g_type = 0;
-		gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val);
-		node = g_value_get_pointer(&val);
+		gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1);
 		gtk_selection_data_set (data,
 					gdk_atom_intern ("PURPLE_BLIST_NODE", FALSE),
 					8, /* bits */
@@ -2297,7 +2265,6 @@ static void pidgin_blist_drag_data_get_c
 		PurpleBlistNode *node = NULL;
 		PurpleBuddy *buddy;
 		PurpleConnection *gc;
-		GValue val;
 		GString *str;
 		const char *protocol;
 
@@ -2309,12 +2276,8 @@ static void pidgin_blist_drag_data_get_c
 
 		gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter,
 								sourcerow);
-		val.g_type = 0;
-		gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), &iter,
-								 NODE_COLUMN, &val);
+		gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1);
 
-		node = g_value_get_pointer(&val);
-
 		if (PURPLE_BLIST_NODE_IS_CONTACT(node))
 		{
 			buddy = purple_contact_get_priority_buddy((PurpleContact *)node);
@@ -2387,15 +2350,12 @@ static void pidgin_blist_drag_data_rcv_c
 			/* if we're here, I think it means the drop is ok */
 			GtkTreeIter iter;
 			PurpleBlistNode *node;
-			GValue val;
 			struct _pidgin_blist_node *gtknode;
 
 			gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel),
 					&iter, path);
-			val.g_type = 0;
-			gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel),
-					&iter, NODE_COLUMN, &val);
-			node = g_value_get_pointer(&val);
+			gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel),
+					&iter, NODE_COLUMN, &node, -1);
 			gtknode = node->ui_data;
 
 			if (PURPLE_BLIST_NODE_IS_CONTACT(n)) {
@@ -2540,14 +2500,11 @@ static void pidgin_blist_drag_data_rcv_c
 		{
 			GtkTreeIter iter;
 			PurpleBlistNode *node;
-			GValue val;
 
 			gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel),
 									&iter, path);
-			val.g_type = 0;
-			gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel),
-									  &iter, NODE_COLUMN, &val);
-			node = g_value_get_pointer(&val);
+			gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel),
+				&iter, NODE_COLUMN, &node, -1);
 
 			if (PURPLE_BLIST_NODE_IS_BUDDY(node))
 			{
@@ -2602,14 +2559,11 @@ static void pidgin_blist_drag_data_rcv_c
 		{
 			GtkTreeIter iter;
 			PurpleBlistNode *node;
-			GValue val;
 
 			gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel),
 									&iter, path);
-			val.g_type = 0;
-			gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel),
-									  &iter, NODE_COLUMN, &val);
-			node = g_value_get_pointer(&val);
+			gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel),
+				&iter, NODE_COLUMN, &node, -1);
 
 			if (PURPLE_BLIST_NODE_IS_BUDDY(node))
 			{
@@ -2638,14 +2592,11 @@ static void pidgin_blist_drag_data_rcv_c
 			{
 				GtkTreeIter iter;
 				PurpleBlistNode *node;
-				GValue val;
 
 				gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel),
 							&iter, path);
-				val.g_type = 0;
-				gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel),
-							  &iter, NODE_COLUMN, &val);
-				node = g_value_get_pointer(&val);
+				gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel),
+					&iter, NODE_COLUMN, &node, -1);
 
 				if (PURPLE_BLIST_NODE_IS_BUDDY(node) || PURPLE_BLIST_NODE_IS_CONTACT(node)) {
 					PurpleBuddy *b = PURPLE_BLIST_NODE_IS_BUDDY(node) ? PURPLE_BUDDY(node) : purple_contact_get_priority_buddy(PURPLE_CONTACT(node));
@@ -3210,16 +3161,13 @@ static gboolean pidgin_blist_expand_time
 	GtkTreePath *path;
 	GtkTreeIter iter;
 	PurpleBlistNode *node;
-	GValue val;
 	struct _pidgin_blist_node *gtknode;
 
 	if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), gtkblist->tip_rect.x, gtkblist->tip_rect.y + (gtkblist->tip_rect.height/2),
 		&path, NULL, NULL, NULL))
 		return FALSE;
 	gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path);
-	val.g_type = 0;
-	gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val);
-	node = g_value_get_pointer(&val);
+	gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1);
 
 	if(!PURPLE_BLIST_NODE_IS_CONTACT(node)) {
 		gtk_tree_path_free(path);
@@ -3323,7 +3271,6 @@ pidgin_blist_create_tooltip(GtkWidget *w
 {
 	GtkTreeIter iter;
 	PurpleBlistNode *node;
-	GValue val;
 	gboolean editable = FALSE;
 
 	/* If we're editing a cell (e.g. alias editing), don't show the tooltip */
@@ -3337,9 +3284,8 @@ pidgin_blist_create_tooltip(GtkWidget *w
 	}
 
 	gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path);
-	val.g_type = 0;
-	gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val);
-	node = g_value_get_pointer(&val);
+	gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1);
+
 	return pidgin_blist_create_tooltip_for_node(widget, node, w, h);
 }
 
@@ -7744,14 +7690,11 @@ static void sort_method_alphabetical(Pur
 	}
 
 	do {
-		GValue val;
 		PurpleBlistNode *n;
 		const char *this_name;
 		int cmp;
 
-		val.g_type = 0;
-		gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &more_z, NODE_COLUMN, &val);
-		n = g_value_get_pointer(&val);
+		gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &more_z, NODE_COLUMN, &n, -1);
 
 		if(PURPLE_BLIST_NODE_IS_CONTACT(n)) {
 			this_name = purple_contact_get_alias((PurpleContact*)n);
@@ -7774,7 +7717,6 @@ static void sort_method_alphabetical(Pur
 				return;
 			}
 		}
-		g_value_unset(&val);
 	} while (gtk_tree_model_iter_next (GTK_TREE_MODEL(gtkblist->treemodel), &more_z));
 
 	if(cur) {
@@ -7815,14 +7757,11 @@ static void sort_method_status(PurpleBli
 	}
 
 	do {
-		GValue val;
 		PurpleBlistNode *n;
 		gint name_cmp;
 		gint presence_cmp;
 
-		val.g_type = 0;
-		gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &more_z, NODE_COLUMN, &val);
-		n = g_value_get_pointer(&val);
+		gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &more_z, NODE_COLUMN, &n, -1);
 
 		if(PURPLE_BLIST_NODE_IS_CONTACT(n)) {
 			this_buddy = purple_contact_get_priority_buddy((PurpleContact*)n);
@@ -7858,8 +7797,6 @@ static void sort_method_status(PurpleBli
 				return;
 			}
 		}
-
-		g_value_unset(&val);
 	}
 	while (gtk_tree_model_iter_next(GTK_TREE_MODEL(gtkblist->treemodel),
 									&more_z));
@@ -7916,15 +7853,12 @@ static void sort_method_log_activity(Pur
 	}
 
 	do {
-		GValue val;
 		PurpleBlistNode *n;
 		PurpleBlistNode *n2;
 		PurpleBuddy *buddy;
 		int cmp;
 
-		val.g_type = 0;
-		gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &more_z, NODE_COLUMN, &val);
-		n = g_value_get_pointer(&val);
+		gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &more_z, NODE_COLUMN, &n, -1);
 		this_log_activity_score = 0;
 
 		if(PURPLE_BLIST_NODE_IS_CONTACT(n)) {
@@ -7952,7 +7886,6 @@ static void sort_method_log_activity(Pur
 				return;
 			}
 		}
-		g_value_unset(&val);
 	} while (gtk_tree_model_iter_next (GTK_TREE_MODEL(gtkblist->treemodel), &more_z));
 
 	if (cur != NULL) {


More information about the Commits mailing list