[gthumb] thumb loader: do not recreate the factory if the size didn't change



commit ae9de9ce97c092e6f30a0dfa8f055b66ad2ed98f
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sun Sep 19 11:29:11 2010 +0200

    thumb loader: do not recreate the factory if the size didn't change

 gthumb/gth-thumb-loader.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/gthumb/gth-thumb-loader.c b/gthumb/gth-thumb-loader.c
index eacf371..6ca342d 100644
--- a/gthumb/gth-thumb-loader.c
+++ b/gthumb/gth-thumb-loader.c
@@ -245,21 +245,23 @@ void
 gth_thumb_loader_set_requested_size (GthThumbLoader *self,
 				     int             size)
 {
-	if (self->priv->thumb_factory != NULL) {
-		g_object_unref (self->priv->thumb_factory);
-		self->priv->thumb_factory = NULL;
-	}
+	GnomeDesktopThumbnailSize thumb_size;
 
 	self->priv->requested_size = size;
 	if (self->priv->requested_size <= THUMBNAIL_NORMAL_SIZE) {
 		self->priv->cache_max_size = THUMBNAIL_NORMAL_SIZE;
-		self->priv->thumb_size = GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL;
+		thumb_size = GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL;
 	}
 	else {
 		self->priv->cache_max_size = THUMBNAIL_LARGE_SIZE;
-		self->priv->thumb_size = GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE;
+		thumb_size = GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE;
+	}
+
+	if ((self->priv->thumb_size != thumb_size) || (self->priv->thumb_factory == NULL)) {
+		self->priv->thumb_size = thumb_size;
+		_g_object_unref (self->priv->thumb_factory);
+		self->priv->thumb_factory = gnome_desktop_thumbnail_factory_new (self->priv->thumb_size);
 	}
-	self->priv->thumb_factory = gnome_desktop_thumbnail_factory_new (self->priv->thumb_size);
 }
 
 



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