# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: geoffrey.antos@gmail.com-20080731193958-\
#   mk8ow9wy2m82ggp3
# target_branch: ../upstream/
# testament_sha1: 2b7d2f5b556fd39c074f8ff1dc0991ee80e68909
# timestamp: 2008-07-31 15:40:56 -0400
# source_branch: .
# base_revision_id: geoffrey.antos@gmail.com-20080731010416-\
#   074dgm6xx0qzxvko
# 
# Begin patch
=== modified file 'ChangeLog'
--- ChangeLog	2008-07-31 01:04:16 +0000
+++ ChangeLog	2008-07-31 19:39:58 +0000
@@ -1,3 +1,12 @@
+2008-07-31  Geoffrey Antos <dynamotwain@aim.com>
+	* libgthumb/image-loader.c: (image_loader_set_pixbuf)
+		When setting a static pixbuf, free any loaded animation
+		as animations override static pixbufs.
+	
+	* libgthumb/image-viewer.c: (image_viewer_set_pixbuf):
+		Fix a potential race-condition if called while still
+		loading an image.
+
 2008-07-30  Geoffrey Antos <dynamotwain@aim.com>
 	* libgthumb/gth-nav-window.c: (size_changed_cb):
 		Remove assumptions about GtkAdjustment->lower being 0

=== modified file 'libgthumb/image-loader.c'
--- libgthumb/image-loader.c	2007-11-22 20:55:33 +0000
+++ libgthumb/image-loader.c	2008-07-31 19:39:58 +0000
@@ -417,6 +417,10 @@
 	g_return_if_fail (pixbuf != NULL);
 
 	g_mutex_lock (il->priv->data_mutex);
+	if (il->priv->animation != NULL) {
+		g_object_unref (il->priv->animation);
+		il->priv->animation = NULL;
+	}
 	if (il->priv->pixbuf != NULL) {
 		g_object_unref (il->priv->pixbuf);
 		il->priv->pixbuf = NULL;

=== modified file 'libgthumb/image-viewer-image.c'
--- libgthumb/image-viewer-image.c	2008-07-31 01:04:16 +0000
+++ libgthumb/image-viewer-image.c	2008-07-31 19:39:58 +0000
@@ -1011,7 +1011,6 @@
 			  cairo_t          *cr)
 {
 	ImageViewerImagePrivate *priv;
-	GdkPixbuf               *pixbuf;
 	GtkStyle                *style;
 
 	gint                     border, border2;
@@ -1027,7 +1026,6 @@
 	g_return_if_fail (image != NULL);
 
 	priv   = IMAGE_VIEWER_IMAGE_GET_PRIVATE (image);
-	pixbuf = image_viewer_image_get_pixbuf (image);
 	style  = GTK_WIDGET (priv->viewer)->style;
 
 	if (image_viewer_is_frame_visible (priv->viewer)) {

=== modified file 'libgthumb/image-viewer.c'
--- libgthumb/image-viewer.c	2008-07-31 01:04:16 +0000
+++ libgthumb/image-viewer.c	2008-07-31 19:39:58 +0000
@@ -1354,19 +1354,42 @@
 }
 
 
+static void
+set_pixbuf__step2 (ImageViewerLoadData *ivl_data)
+{
+	ImageViewerPrivate *priv   = IMAGE_VIEWER_GET_PRIVATE (ivl_data->viewer);
+	GdkPixbuf          *pixbuf = ivl_data->data;
+
+	image_loader_set_file   (priv->loader, NULL);
+	image_loader_set_pixbuf (priv->loader, pixbuf);
+	image_loaded (priv->loader, ivl_data->viewer);
+
+	g_object_unref (G_OBJECT (pixbuf));
+	g_free (ivl_data);
+
+}
+
+
 void
 image_viewer_set_pixbuf (ImageViewer *viewer,
 			 GdkPixbuf   *pixbuf)
 {
-	ImageViewerPrivate* priv;
+	ImageViewerPrivate  *priv;
+	ImageViewerLoadData *ivl_data;
 
 	g_return_if_fail (viewer != NULL);
 
 	priv = IMAGE_VIEWER_GET_PRIVATE (viewer);
 
-	image_loader_set_pixbuf (priv->loader, pixbuf);
-
-	image_loaded (priv->loader, viewer);
+	ivl_data = g_new0 (ImageViewerLoadData, 1);
+	ivl_data->viewer = viewer;
+	ivl_data->data = pixbuf;
+	g_object_ref (G_OBJECT (pixbuf));
+
+	image_loader_stop (priv->loader,
+			   (DoneFunc) set_pixbuf__step2,
+			   ivl_data);
+
 }
 
 

