pidgin.next.minor: 65a6cbe8: This patch fixes a few string leaks (don...

grim at pidgin.im grim at pidgin.im
Mon Jan 5 23:01:27 EST 2009


-----------------------------------------------------------------
Revision: 65a6cbe8469f96b691eebe7e4a5ff2d5b8d4eaa8
Ancestor: 37221dd9c6eb8efec0e43ab134ad459d760858e4
Author: paul at aurich.com
Date: 2009-01-06T03:50:44
Branch: im.pidgin.pidgin.next.minor
URL: http://d.pidgin.im/viewmtn/revision/info/65a6cbe8469f96b691eebe7e4a5ff2d5b8d4eaa8

Modified files:
        pidgin/gtkblist.c

ChangeLog: 

This patch fixes a few string leaks (don't g_strdup the FontColorPair? values) and also fixes the bug where, with no theme, everyone on the buddy list is colored "dim grey" (chunks 2, 3, and 4 in the patch)

refs #7760


-------------- next part --------------
============================================================
--- pidgin/gtkblist.c	7a4f7641d9eb447b39e15a5e1ae5c594e6c99331
+++ pidgin/gtkblist.c	7e088cc6e9f53526580c48856fc5839faa0f8e3c
@@ -784,10 +784,10 @@ static void gtk_blist_menu_showlog_cb(Gt
 
 	if (name && account) {
 		pidgin_log_show(type, name, account);
-		g_free(name);
-
 		pidgin_clear_cursor(gtkblist->window);
 	}
+
+	g_free(name);
 }
 
 static void gtk_blist_menu_showoffline_cb(GtkWidget *w, PurpleBlistNode *node)
@@ -3866,7 +3866,7 @@ pidgin_blist_get_name_markup(PurpleBuddy
 	PurpleConversation *conv = find_conversation_with_buddy(b);
 	gboolean hidden_conv = FALSE;
 	gboolean biglist = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons");
-	FontColorPair *pair;
+	FontColorPair *pair = NULL;
 	PidginBlistTheme *theme;
 
 	if (conv != NULL) {
@@ -3984,39 +3984,42 @@ pidgin_blist_get_name_markup(PurpleBuddy
 	/* choose the colors of the text */
 	theme = pidgin_blist_get_theme();
 
-	if (theme == NULL) {
-		status_color = name_color = "dim grey";
-		status_font = name_font = "";
-
-	} else  if (purple_presence_is_idle(presence)) {
-		pair = pidgin_blist_theme_get_idle_text_info(theme);
+	if (purple_presence_is_idle(presence)) {
+		if (theme)
+			pair = pidgin_blist_theme_get_idle_text_info(theme);
 		status_color = name_color = (pair != NULL && pair->color != NULL) ? pair->color : "dim grey";
 		status_font = name_font = (pair != NULL && pair->font != NULL) ? pair->font : "";
 
 	} else if (!purple_presence_is_online(presence)) {
-		pair = pidgin_blist_theme_get_offline_text_info(theme);
+		if (theme)
+			pair = pidgin_blist_theme_get_offline_text_info(theme);
 		name_color = (pair != NULL && pair->color != NULL) ? pair->color : "black";
 		name_font = (pair != NULL && pair->font != NULL) ? pair->font : "";
 
-		pair = pidgin_blist_theme_get_status_text_info(theme);
-		status_color = (pair != NULL && pair->color != NULL) ? g_strdup(pair->color) : "dim grey";
+		if (theme)
+			pair = pidgin_blist_theme_get_status_text_info(theme);
+		status_color = (pair != NULL && pair->color != NULL) ? pair->color : "dim grey";
 		status_font = (pair != NULL && pair->font != NULL) ? pair->font : "";
 
 	} else if (purple_presence_is_available(presence)) {
-		pair = pidgin_blist_theme_get_online_text_info(theme);
-		name_color = (pair != NULL && pair->color != NULL) ? g_strdup(pair->color) : "black";
+		if (theme)
+			pair = pidgin_blist_theme_get_online_text_info(theme);
+		name_color = (pair != NULL && pair->color != NULL) ? pair->color : "black";
 		name_font = (pair != NULL && pair->font != NULL) ? pair->font : "";
 
-		pair = pidgin_blist_theme_get_status_text_info(theme);
+		if (theme)
+			pair = pidgin_blist_theme_get_status_text_info(theme);
 		status_color = (pair != NULL && pair->color != NULL) ? pair->color : "dim grey";
 		status_font = (pair != NULL && pair->font != NULL) ? pair->font : "";
 
 	} else {
-		pair = pidgin_blist_theme_get_away_text_info(theme);
+		if (theme)
+			pair = pidgin_blist_theme_get_away_text_info(theme);
 		name_color = (pair != NULL && pair->color != NULL) ? pair->color : "black";
 		name_font = (pair != NULL && pair->font != NULL) ? pair->font : "";
 
-		pair = pidgin_blist_theme_get_status_text_info(theme);
+		if (theme)
+			pair = pidgin_blist_theme_get_status_text_info(theme);
 		status_color = (pair != NULL && pair->color != NULL) ? pair->color : "dim grey";
 		status_font = (pair != NULL && pair->font != NULL) ? pair->font : "";
 	}
@@ -6297,27 +6300,31 @@ static void pidgin_blist_update_contact(
 
 		if(gtknode->contact_expanded) {
 			GdkPixbuf *status;
-			gchar *mark;
+			gchar *mark, *tmp;
+			const gchar *fg_color, *font;
 			GdkColor *color = NULL;
 			PidginBlistTheme *theme = pidgin_blist_get_theme();
+			FontColorPair *pair;
 			gboolean selected = (gtkblist->selected_node == cnode);
-			
+
 			mark = g_markup_escape_text(purple_contact_get_alias(contact), -1);
 
-			if (theme != NULL) {
-				FontColorPair *pair = pidgin_blist_theme_get_contact_text_info(theme);
+			theme = pidgin_blist_get_theme();
+			if (theme == NULL)
+				pair = NULL;
+			else {
+				pair = pidgin_blist_theme_get_contact_text_info(theme);
 				color = pidgin_blist_theme_get_contact_color(theme);
+			}
 
-				if (pair != NULL) {
-					gchar *temp = g_strdup_printf("<span foreground='%s' font_desc='%s'>%s</span>",
-								     (selected || pair->color == NULL) ? "black" : pair->color,
-								     (pair->font == NULL) ? "" : pair->font, mark);
-				
-					g_free(mark);
-					mark = temp;
-				}
-			}
+			font = (pair == NULL || pair->font == NULL) ? "" : pair->font;
+			fg_color = (selected || pair == NULL || pair->color == NULL) ? "black" : pair->color;
 
+			tmp = g_strdup_printf("<span font_desc='%s' color='%s'>%s</span>",
+						font, fg_color, mark);
+			g_free(mark);
+			mark = tmp;
+
 			status = pidgin_blist_get_status_icon(cnode,
 					 biglist? PIDGIN_STATUS_ICON_LARGE : PIDGIN_STATUS_ICON_SMALL);
 			
@@ -6434,8 +6441,8 @@ static void pidgin_blist_update_chat(Pur
 			pair = pidgin_blist_theme_get_unread_message_text_info(theme);
 		else pair = pidgin_blist_theme_get_online_text_info(theme); 
 			
-		font = (pair == NULL || pair->font == NULL) ? "" : g_strdup(pair->font);
-		color = (selected || pair == NULL || pair->color == NULL) ? "black" : g_strdup(pair->color);
+		font = (pair == NULL || pair->font == NULL) ? "" : pair->font;
+		color = (selected || pair == NULL || pair->color == NULL) ? "black" : pair->color;
 
 		tmp = g_strdup_printf("<span font_desc='%s' color='%s' weight='%s'>%s</span>", 
 				      font, color, hidden ? "bold" : "normal", mark);


More information about the Commits mailing list