pidgin: b687754d: Do not try to update received custom smi...

sadrul at pidgin.im sadrul at pidgin.im
Sat May 31 11:45:45 EDT 2008


-----------------------------------------------------------------
Revision: b687754dfefde18bbb1a2652261943517272a691
Ancestor: d60c8368897067a25f4d251f0a392624b27cef42
Author: sadrul at pidgin.im
Date: 2008-05-31T13:30:28
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/b687754dfefde18bbb1a2652261943517272a691

Modified files:
        pidgin/gtkimhtml.c

ChangeLog: 

Do not try to update received custom smileys in a deleted child anchor.
This used to cause a crash if scrollback was cleared before the image
data for the custom smiley had arrived. Fixes #5964.

-------------- next part --------------
============================================================
--- pidgin/gtkimhtml.c	4b05a7ac81f4713fd1a248c25c09e26e4e6abf90
+++ pidgin/gtkimhtml.c	e6ae0026feb971ac37aa58db52e57945453e052c
@@ -4866,7 +4866,7 @@ void gtk_imhtml_insert_smiley_at_iter(Gt
 		gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), ebox ? ebox : icon, anchor);
 	} else if (imhtml_smiley != NULL && (imhtml->format_functions & GTK_IMHTML_SMILEY)) {
 		anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter);
-		imhtml_smiley->anchors = g_slist_append(imhtml_smiley->anchors, anchor);
+		imhtml_smiley->anchors = g_slist_append(imhtml_smiley->anchors, g_object_ref(anchor));
 		if (ebox) {
 			GtkWidget *img = gtk_image_new_from_stock(GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_MENU);
 			char *text = g_strdup(unescaped);
@@ -5506,9 +5506,12 @@ static void gtk_custom_smiley_closed(Gdk
 	}
 
 	for (current = smiley->anchors; current; current = g_slist_next(current)) {
+		anchor = GTK_TEXT_CHILD_ANCHOR(current->data);
+		if (gtk_text_child_anchor_get_deleted(anchor))
+			icon = NULL;
+		else
+			icon = gtk_image_new_from_animation(smiley->icon);
 
-		icon = gtk_image_new_from_animation(smiley->icon);
-
 #ifdef DEBUG_CUSTOM_SMILEY
 		purple_debug_info("custom-smiley", "gtk_custom_smiley_closed(): got GtkImage %p from GtkPixbufAnimation %p for smiley '%s'\n",
 				icon, smiley->icon, smiley->smile);
@@ -5517,7 +5520,6 @@ static void gtk_custom_smiley_closed(Gdk
 			GList *wids;
 			gtk_widget_show(icon);
 
-			anchor = GTK_TEXT_CHILD_ANCHOR(current->data);
 			wids = gtk_text_child_anchor_get_widgets(anchor);
 
 			g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", purple_unescape_html(smiley->smile), g_free);
@@ -5534,7 +5536,7 @@ static void gtk_custom_smiley_closed(Gdk
 			}
 			g_list_free(wids);
 		}
-
+		g_object_unref(anchor);
 	}
 
 	g_slist_free(smiley->anchors);


More information about the Commits mailing list