[gimp/gimp-2-8] app: gimp_brush_load_brush(): add special error for possible old files



commit 1fa53c46708c9ceab34c3b97361f99ca7a5cb531
Author: Michael Natterer <mitch gimp org>
Date:   Sun Nov 17 01:22:52 2013 +0100

    app: gimp_brush_load_brush(): add special error for possible old files
    
    The obsolete .gbp format had a 3-byte pattern following a 1-byte
    brush, when embedded in a brush pipe, the current code tries to load
    that pattern as a brush, and encounters the '3' in the header. Detect
    that and suggest to re-save the file because the plug-in still loads
    the legacy format.
    
    (cherry picked from commit 83bd1c86faa293b1c6456147395be18ade24f748)

 app/core/gimpbrush-load.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimpbrush-load.c b/app/core/gimpbrush-load.c
index 830d17a..e7c353b 100644
--- a/app/core/gimpbrush-load.c
+++ b/app/core/gimpbrush-load.c
@@ -343,6 +343,23 @@ gimp_brush_load_brush (GimpContext  *context,
       }
       break;
 
+    case 3:
+      /* The obsolete .gbp format had a 3-byte pattern following a
+       * 1-byte brush, when embedded in a brush pipe, the current code
+       * tries to load that pattern as a brush, and encounters the '3'
+       * in the header.
+       */
+      g_object_unref (brush);
+      g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
+                   _("Fatal parse error in brush file '%s': "
+                     "Unsupported brush depth %d\n"
+                     "GIMP brushes must be GRAY or RGBA.\n"
+                     "This might be an obsolete GIMP brush file, try "
+                     "loading it as image and save it again."),
+                   gimp_filename_to_utf8 (filename), header.bytes);
+      return NULL;
+      break;
+
     case 4:
       {
         guchar buf[8 * 1024];


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