[gimp] Bug 622758 - Fix error display for thumbnail creation



commit 6208d2197941f5650e869d83e542a05fe4894244
Author: Jehan <jehan girinstud io>
Date:   Mon Dec 23 03:25:05 2013 +1300

    Bug 622758 - Fix error display for thumbnail creation
    
    Do not stay forever in "Creating Preview..." state during
    auto-thumbnailing, and fix error showing when creation fails.

 app/core/gimpimagefile.c     |   20 ++++++++++++++++++--
 libgimpthumb/gimpthumbnail.c |    5 +++--
 2 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/app/core/gimpimagefile.c b/app/core/gimpimagefile.c
index e423833..643c5fb 100644
--- a/app/core/gimpimagefile.c
+++ b/app/core/gimpimagefile.c
@@ -441,6 +441,13 @@ gimp_imagefile_create_thumbnail (GimpImagefile  *imagefile,
 
       g_object_unref (imagefile);
 
+      if (! success)
+        {
+          g_object_set (thumbnail,
+                        "thumb-state", GIMP_THUMB_STATE_FAILED,
+                        NULL);
+        }
+
       return success;
     }
 
@@ -478,8 +485,17 @@ gimp_imagefile_create_thumbnail_weak (GimpImagefile *imagefile,
 
   g_object_add_weak_pointer (G_OBJECT (imagefile), (gpointer) &imagefile);
 
-  gimp_imagefile_create_thumbnail (local, context, progress, size, replace,
-                                   NULL);
+  if (! gimp_imagefile_create_thumbnail (local, context, progress, size, replace,
+                                         NULL))
+    {
+      /* The weak version works on a local copy so the thumbnail status
+       * of the actual image is not properly updated in case of creation
+       * failure, thus it would end up in a generic GIMP_THUMB_STATE_NOT_FOUND,
+       * which is less informative. */
+      g_object_set (private->thumbnail,
+                    "thumb-state", GIMP_THUMB_STATE_FAILED,
+                    NULL);
+    }
 
   if (imagefile)
     {
diff --git a/libgimpthumb/gimpthumbnail.c b/libgimpthumb/gimpthumbnail.c
index 30cc191..fc90e41 100644
--- a/libgimpthumb/gimpthumbnail.c
+++ b/libgimpthumb/gimpthumbnail.c
@@ -710,14 +710,15 @@ gimp_thumbnail_update_thumb (GimpThumbnail *thumbnail,
 
   filename = gimp_thumb_find_thumb (thumbnail->image_uri, &size);
 
-  if (! filename)
+  /* We don't want to clear the GIMP_THUMB_STATE_FAILED state, because
+   * it is normal to have no filename if thumbnail creation failed. */
+  if (state != GIMP_THUMB_STATE_FAILED && ! filename)
     state = GIMP_THUMB_STATE_NOT_FOUND;
 
   switch (state)
     {
     case GIMP_THUMB_STATE_EXISTS:
     case GIMP_THUMB_STATE_OLD:
-    case GIMP_THUMB_STATE_FAILED:
     case GIMP_THUMB_STATE_OK:
       g_return_if_fail (thumbnail->thumb_filename != NULL);
 


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