[gimp] app: improve error message when failing to load an ABR version 6 brush



commit 47c94fc2280c87cee9c9e735ae1a5a6569e7dc9c
Author: Michael Natterer <mitch gimp org>
Date:   Sat Aug 4 00:04:47 2012 +0200

    app: improve error message when failing to load an ABR version 6 brush

 app/core/gimpbrush-load.c |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/app/core/gimpbrush-load.c b/app/core/gimpbrush-load.c
index 67d5a9f..f4dfdbc 100644
--- a/app/core/gimpbrush-load.c
+++ b/app/core/gimpbrush-load.c
@@ -110,7 +110,9 @@ static gchar       abr_read_char                 (FILE         *file);
 static gint16      abr_read_short                (FILE         *file);
 static gint32      abr_read_long                 (FILE         *file);
 static gchar     * abr_read_ucs2_text            (FILE         *file);
-static gboolean    abr_supported                 (AbrHeader    *abr_hdr);
+static gboolean    abr_supported                 (AbrHeader    *abr_hdr,
+                                                  const gchar  *filename,
+                                                  GError      **error);
 static gboolean    abr_reach_8bim_section        (FILE         *abr,
                                                   const gchar  *name);
 static gint32      abr_rle_decode                (FILE         *file,
@@ -429,7 +431,7 @@ gimp_brush_load_abr (GimpContext  *context,
   abr_hdr.version = abr_read_short (file);
   abr_hdr.count   = abr_read_short (file); /* sub-version for ABR v6 */
 
-  if (abr_supported (&abr_hdr))
+  if (abr_supported (&abr_hdr, filename, error))
     {
       switch (abr_hdr.version)
         {
@@ -833,7 +835,9 @@ abr_read_ucs2_text (FILE *file)
 }
 
 static gboolean
-abr_supported (AbrHeader *abr_hdr)
+abr_supported (AbrHeader    *abr_hdr,
+               const gchar  *filename,
+               GError      **error)
 {
   switch (abr_hdr->version)
     {
@@ -846,6 +850,18 @@ abr_supported (AbrHeader *abr_hdr)
       /* in this case, count contains format sub-version */
       if (abr_hdr->count == 1 || abr_hdr->count == 2)
         return TRUE;
+
+      if (error && ! (*error))
+        g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
+                     _("Fatal parse error in brush file '%s': "
+                       "unable to decode abr format version %d."),
+                     gimp_filename_to_utf8 (filename),
+
+                     /* horrid subversion display, but better than
+                      * having yet another translatable string for
+                      * this
+                      */
+                     abr_hdr->version * 10 + abr_hdr->count);
       break;
     }
 



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