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



commit 443c171f8dd5459462935165fa208b773cb2c930
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).

 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 1ce6933eee..1910ef082f 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);
@@ -754,11 +752,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]