[gimp/gimp-2-10] plug-ins: babl_init|exit() for non-interactive "file-pdf-load" too.



commit 8164d7f26daf988f5699a04deb45250368324069
Author: Jehan <jehan girinstud io>
Date:   Mon Jul 22 12:33:27 2019 +0200

    plug-ins: babl_init|exit() for non-interactive "file-pdf-load" too.
    
    Improve my previous commit: I added babl_init|exit() for
    "file-pdf-load-thumb". But these was actually also missing from
    non-interactive calls to "file-pdf-load", since the initialization was
    done as part of gimp_ui_init() so far.
    Just run them down the call stack around the needed part. It's not a
    problem if it's called double (for the interactive code path).
    
    (cherry picked from commit 443c171f8dd5459462935165fa208b773cb2c930)

 plug-ins/common/file-pdf-load.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/plug-ins/common/file-pdf-load.c b/plug-ins/common/file-pdf-load.c
index 9c8a343607..3dec4c892b 100644
--- a/plug-ins/common/file-pdf-load.c
+++ b/plug-ins/common/file-pdf-load.c
@@ -613,9 +613,7 @@ run (const gchar      *name,
               gimp_image_undo_disable (image);
 
 
-              babl_init ();
               layer_from_surface (image, "thumbnail", 0, surface, 0.0, 1.0);
-              babl_exit ();
               cairo_surface_destroy (surface);
 
               gimp_image_undo_enable (image);
@@ -935,11 +933,19 @@ layer_from_surface (gint32           image,
                     gdouble          progress_start,
                     gdouble          progress_scale)
 {
-  gint32 layer = gimp_layer_new_from_surface (image, layer_name, surface,
-                                              progress_start,
-                                              progress_start + progress_scale);
+  gint32 layer;
 
+  /* This may have already been run for the interactive code path,
+   * as part of gimp_ui_init(), but it doesn't hurt to init again
+   * (needed for non-interactive calls too), as long as we match the
+   * exit.
+   */
+  babl_init ();
+  layer = gimp_layer_new_from_surface (image, layer_name, surface,
+                                       progress_start,
+                                       progress_start + progress_scale);
   gimp_image_insert_layer (image, layer, -1, position);
+  babl_exit ();
 
   return layer;
 }


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