changeset 20210:9d359c1b2df6

applied changes from fc7837d892e8ddb52a2c4c265562c73b6f07f045 through 23f10058988472a234b0d4870c83d0f6136da47d
author Richard Laager <rlaager@wiktel.com>
date Fri, 28 Sep 2007 15:38:37 +0000
parents 9c1df4f7a722
children a5d366d614f5
files pidgin/gtkimhtml.c
diffstat 1 files changed, 30 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkimhtml.c	Fri Sep 28 15:38:22 2007 +0000
+++ b/pidgin/gtkimhtml.c	Fri Sep 28 15:38:37 2007 +0000
@@ -3210,24 +3210,25 @@
 	im_image = data;
 
 	/* Update the pointer to this GdkPixbuf frame of the animation */
-	g_object_unref(G_OBJECT(im_image->pixbuf));
-	gdk_pixbuf_animation_iter_advance(GTK_IMHTML_ANIMATION(im_image)->iter, NULL);
-	im_image->pixbuf = gdk_pixbuf_animation_iter_get_pixbuf(GTK_IMHTML_ANIMATION(im_image)->iter);
-	g_object_ref(G_OBJECT(im_image->pixbuf));
-
-	/* Update the displayed GtkImage */
-	width = gdk_pixbuf_get_width(gtk_image_get_pixbuf(im_image->image));
-	height = gdk_pixbuf_get_height(gtk_image_get_pixbuf(im_image->image));
-	if (width > 0 && height > 0)
-	{
-		/* Need to scale the new frame to the same size as the old frame */
-		GdkPixbuf *tmp;
-		tmp = gdk_pixbuf_scale_simple(im_image->pixbuf, width, height, GDK_INTERP_BILINEAR);
-		gtk_image_set_from_pixbuf(im_image->image, tmp);
-		g_object_unref(G_OBJECT(tmp));
-	} else {
-		/* Display at full-size */
-		gtk_image_set_from_pixbuf(im_image->image, im_image->pixbuf);
+	if (gdk_pixbuf_animation_iter_advance(GTK_IMHTML_ANIMATION(im_image)->iter, NULL)) {
+		GdkPixbuf *pb = gdk_pixbuf_animation_iter_get_pixbuf(GTK_IMHTML_ANIMATION(im_image)->iter);
+		g_object_unref(G_OBJECT(im_image->pixbuf));
+		im_image->pixbuf = gdk_pixbuf_copy(pb);
+
+		/* Update the displayed GtkImage */
+		width = gdk_pixbuf_get_width(gtk_image_get_pixbuf(im_image->image));
+		height = gdk_pixbuf_get_height(gtk_image_get_pixbuf(im_image->image));
+		if (width > 0 && height > 0)
+		{
+			/* Need to scale the new frame to the same size as the old frame */
+			GdkPixbuf *tmp;
+			tmp = gdk_pixbuf_scale_simple(im_image->pixbuf, width, height, GDK_INTERP_BILINEAR);
+			gtk_image_set_from_pixbuf(im_image->image, tmp);
+			g_object_unref(G_OBJECT(tmp));
+		} else {
+			/* Display at full-size */
+			gtk_image_set_from_pixbuf(im_image->image, im_image->pixbuf);
+		}
 	}
 
 	delay = MIN(gdk_pixbuf_animation_iter_get_delay_time(GTK_IMHTML_ANIMATION(im_image)->iter), 100);
@@ -3248,11 +3249,14 @@
 	if (gdk_pixbuf_animation_is_static_image(anim)) {
 		GTK_IMHTML_ANIMATION(im_image)->iter = NULL;
 		im_image->pixbuf = gdk_pixbuf_animation_get_static_image(anim);
+		g_object_ref(im_image->pixbuf);
 		GTK_IMHTML_ANIMATION(im_image)->timer = 0;
 	} else {
 		int delay;
+		GdkPixbuf *pb;
 		GTK_IMHTML_ANIMATION(im_image)->iter = gdk_pixbuf_animation_get_iter(anim, NULL);
-		im_image->pixbuf = gdk_pixbuf_animation_iter_get_pixbuf(GTK_IMHTML_ANIMATION(im_image)->iter);
+		pb = gdk_pixbuf_animation_iter_get_pixbuf(GTK_IMHTML_ANIMATION(im_image)->iter);
+		im_image->pixbuf = gdk_pixbuf_copy(pb);
 		delay = MIN(gdk_pixbuf_animation_iter_get_delay_time(GTK_IMHTML_ANIMATION(im_image)->iter), 100);
 		GTK_IMHTML_ANIMATION(im_image)->timer = g_timeout_add(delay, animate_image_cb, im_image);
 	}
@@ -3265,7 +3269,6 @@
 	im_image->filesel = NULL;
 
 	g_object_ref(anim);
-	g_object_ref(im_image->pixbuf);
 
 	return GTK_IMHTML_SCALABLE(im_image);
 }
@@ -4605,10 +4608,15 @@
 				if (imhtml->num_animations == 20) {
 					GtkImage *image = GTK_IMAGE(g_queue_pop_head(imhtml->animations));
 					GdkPixbufAnimation *anim = gtk_image_get_animation(image);
+					g_signal_handlers_disconnect_matched(G_OBJECT(image), G_SIGNAL_MATCH_FUNC,
+							 0, 0, NULL, G_CALLBACK(animated_smiley_destroy_cb), NULL);
 					if (anim) {
 						GdkPixbuf *pb = gdk_pixbuf_animation_get_static_image(anim);
-						gtk_image_set_from_pixbuf(image, pb);
-						g_object_unref(G_OBJECT(pb));
+						if (pb != NULL) {
+							GdkPixbuf *copy = gdk_pixbuf_copy(pb);
+							gtk_image_set_from_pixbuf(image, copy);
+							g_object_unref(G_OBJECT(copy));
+						}
 					}
 				} else {
  					imhtml->num_animations++;