[gthumb: 10/40] fixed crash when the animation is null



commit 181d70b9cfefbc17c7b2d9e889be70e35f8beb34
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Fri Sep 3 13:57:15 2010 +0200

    fixed crash when the animation is null

 gthumb/gth-image-loader.c    |   21 ++++++++++++---------
 gthumb/gth-image-preloader.c |    9 ++++++---
 2 files changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/gthumb/gth-image-loader.c b/gthumb/gth-image-loader.c
index a2a7a90..a472ea2 100644
--- a/gthumb/gth-image-loader.c
+++ b/gthumb/gth-image-loader.c
@@ -265,21 +265,26 @@ load_image_thread (void *thread_data)
 		g_mutex_lock (self->priv->data_mutex);
 
 		self->priv->loader_ready = TRUE;
-		if (self->priv->animation != NULL)
-			g_object_unref (self->priv->animation);
-		self->priv->animation = animation;
-		self->priv->original_width = original_width;
-		self->priv->original_height = original_height;
 
 		if ((animation == NULL) || (error != NULL)) {
 			self->priv->error = error;
 			self->priv->ready = FALSE;
 		}
-		else if (requested_size == self->priv->requested_size) {
+		else if ((self->priv->file != NULL)
+			 && _g_file_equal_uris (file->file, self->priv->file->file)
+			 && (requested_size == self->priv->requested_size))
+		{
+			_g_object_unref (self->priv->animation);
+			self->priv->animation = g_object_ref (animation);
+			self->priv->original_width = original_width;
+			self->priv->original_height = original_height;
+
 			self->priv->error = NULL;
 			self->priv->ready = TRUE;
 		}
 
+		_g_object_unref (animation);
+
 		g_mutex_unlock (self->priv->data_mutex);
 
 		g_object_unref (file);
@@ -646,9 +651,7 @@ check_thread (gpointer data)
 		_gth_image_loader_error (self, error);
 
 	else	/* Add the check again. */
-		self->priv->check_id = g_timeout_add (REFRESH_RATE,
-							 check_thread,
-							 self);
+		self->priv->check_id = g_timeout_add (REFRESH_RATE, check_thread, self);
 
 	return FALSE;
 }
diff --git a/gthumb/gth-image-preloader.c b/gthumb/gth-image-preloader.c
index d05f220..53c4a37 100644
--- a/gthumb/gth-image-preloader.c
+++ b/gthumb/gth-image-preloader.c
@@ -104,15 +104,18 @@ load_next (gpointer data)
 static gboolean
 preloader_need_second_step (Preloader *preloader)
 {
-	int original_width;
-	int original_height;
+	int                 original_width;
+	int                 original_height;
+	GdkPixbufAnimation *animation;
 
 	gth_image_loader_get_original_size (preloader->loader, &original_width, &original_height);
+	animation = gth_image_loader_get_animation (preloader->loader);
 
 	return (! preloader->error
 		&& (preloader->requested_size != -1)
 		&& ((original_width > preloader->requested_size) || (original_height > preloader->requested_size))
-		&& gdk_pixbuf_animation_is_static_image (gth_image_loader_get_animation (preloader->loader)));
+		&& (animation != NULL)
+		&& gdk_pixbuf_animation_is_static_image (animation));
 }
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]