set fallback thumbnail pixbuf only if the loading really fails
authorVladimir Nadvornik <nadvornik@suse.cz>
Thu, 3 Jul 2008 19:38:19 +0000 (19:38 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Thu, 3 Jul 2008 19:38:19 +0000 (19:38 +0000)
src/thumb.c
src/thumb_standard.c

index d121e4f..eb69b91 100644 (file)
@@ -112,6 +112,12 @@ static void thumb_loader_percent_cb(ImageLoader *il, gdouble percent, gpointer d
        if (tl->func_progress) tl->func_progress(tl, tl->data);
 }
 
+static void thumb_loader_set_fallback(ThumbLoader *tl)
+{
+       if (tl->fd->thumb_pixbuf) g_object_unref(tl->fd->thumb_pixbuf);
+       tl->fd->thumb_pixbuf = pixbuf_fallback(tl->fd, tl->max_w, tl->max_h);
+}
+
 static void thumb_loader_done_cb(ImageLoader *il, gpointer data)
 {
        ThumbLoader *tl = data;
@@ -238,6 +244,8 @@ static void thumb_loader_error_cb(ImageLoader *il, gpointer data)
        image_loader_free(tl->il);
        tl->il = NULL;
 
+       thumb_loader_set_fallback(tl);
+       
        if (tl->func_error) tl->func_error(tl, tl->data);
 }
 
@@ -332,8 +340,6 @@ gint thumb_loader_start(ThumbLoader *tl, FileData *fd)
 
        if (!tl->fd) tl->fd = file_data_ref(fd);
 
-       if (tl->fd->thumb_pixbuf) g_object_unref(tl->fd->thumb_pixbuf);
-       tl->fd->thumb_pixbuf = pixbuf_fallback(tl->fd, tl->max_w, tl->max_h);
 
        if (tl->cache_enable)
                {
@@ -403,6 +409,7 @@ gint thumb_loader_start(ThumbLoader *tl, FileData *fd)
 
                image_loader_free(tl->il);
                tl->il = NULL;
+               thumb_loader_set_fallback(tl);
                return FALSE;
                }
 
index f65eb63..6d6c1d0 100644 (file)
@@ -376,6 +376,12 @@ static void thumb_loader_std_save(ThumbLoaderStd *tl, GdkPixbuf *pixbuf)
        g_object_unref(G_OBJECT(pixbuf));
 }
 
+static void thumb_loader_std_set_fallback(ThumbLoaderStd *tl)
+{
+       if (tl->fd->thumb_pixbuf) g_object_unref(tl->fd->thumb_pixbuf);
+       tl->fd->thumb_pixbuf = pixbuf_fallback(tl->fd, tl->requested_width, tl->requested_height);
+}
+
 static GdkPixbuf *thumb_loader_std_finish(ThumbLoaderStd *tl, GdkPixbuf *pixbuf, gint shrunk)
 {
        GdkPixbuf *pixbuf_thumb = NULL;
@@ -581,6 +587,8 @@ static void thumb_loader_std_error_cb(ImageLoader *il, gpointer data)
 
        if (thumb_loader_std_next_source(tl, TRUE)) return;
 
+       thumb_loader_std_set_fallback(tl);
+       
        if (tl->func_error) tl->func_error(tl, tl->data);
 }
 
@@ -648,10 +656,6 @@ gint thumb_loader_std_start(ThumbLoaderStd *tl, FileData *fd)
        if (!tl || !fd) return FALSE;
 
        thumb_loader_std_reset(tl);
-       
-       if (fd->thumb_pixbuf) g_object_unref(fd->thumb_pixbuf);
-       fd->thumb_pixbuf = pixbuf_fallback(fd, tl->requested_width, tl->requested_height);
-
 
        if (!stat_utf8(fd->path, &st)) return FALSE;
 
@@ -681,14 +685,19 @@ gint thumb_loader_std_start(ThumbLoaderStd *tl, FileData *fd)
                found = isfile(tl->thumb_path);
                if (found && thumb_loader_std_setup(tl, tl->thumb_path)) return TRUE;
 
-               if (thumb_loader_std_fail_check(tl)) return FALSE;
-
-               return thumb_loader_std_next_source(tl, found);
+               if (thumb_loader_std_fail_check(tl) ||
+                   !thumb_loader_std_next_source(tl, found))
+                       {
+                       thumb_loader_std_set_fallback(tl);
+                       return FALSE;
+                       }
+               return TRUE;
                }
 
        if (!thumb_loader_std_setup(tl, tl->fd->path))
                {
                thumb_loader_std_save(tl, NULL);
+               thumb_loader_std_set_fallback(tl);
                return FALSE;
                }