[gimp/gimp-2-10] app: in gimp_gegl_apply_cached_operation(), copy cached result *before* rejigging graph



commit bba810a9e5e49ec695394bf5834baf22519d4d48
Author: Ell <ell_se yahoo com>
Date:   Thu Aug 1 23:22:25 2019 +0300

    app: in gimp_gegl_apply_cached_operation(), copy cached result *before* rejigging graph
    
    In gimp_gegl_apply_cached_operation(), copy the cached results to
    the destination buffer *before* reconnecting the operation node, as
    this may cause the cache to be cleared (see commit
    gegl@4347255cd9d5031e6757c70fdde5c63539d5f508).
    
    (cherry picked from commit 35729ee02a6679d8dd525001546f5ca57a926a6a)

 app/gegl/gimp-gegl-apply-operation.c | 132 +++++++++++++++++------------------
 1 file changed, 66 insertions(+), 66 deletions(-)
---
diff --git a/app/gegl/gimp-gegl-apply-operation.c b/app/gegl/gimp-gegl-apply-operation.c
index 1b27295d50..443a27356d 100644
--- a/app/gegl/gimp-gegl-apply-operation.c
+++ b/app/gegl/gimp-gegl-apply-operation.c
@@ -112,6 +112,72 @@ gimp_gegl_apply_cached_operation (GeglBuffer          *src_buffer,
   if (! dest_rect)
     dest_rect = gegl_buffer_get_extent (dest_buffer);
 
+  if (progress)
+    {
+      if (gimp_progress_is_active (progress))
+        {
+          if (undo_desc)
+            gimp_progress_set_text_literal (progress, undo_desc);
+
+          progress_started = FALSE;
+          cancelable       = FALSE;
+        }
+      else
+        {
+          gimp_progress_start (progress, cancelable, "%s", undo_desc);
+
+          if (cancelable)
+            g_signal_connect (progress, "cancel",
+                              G_CALLBACK (gimp_gegl_apply_operation_cancel),
+                              &cancel);
+
+          progress_started = TRUE;
+        }
+    }
+  else
+    {
+      cancelable = FALSE;
+    }
+
+  gegl_buffer_freeze_changed (dest_buffer);
+
+  all_pixels  = dest_rect->width * dest_rect->height;
+  done_pixels = 0;
+
+  region = cairo_region_create_rectangle ((cairo_rectangle_int_t *) dest_rect);
+
+  if (cache)
+    {
+      gint i;
+
+      for (i = 0; i < n_valid_rects; i++)
+        {
+          GeglRectangle valid_rect;
+
+          if (! gegl_rectangle_intersect (&valid_rect,
+                                          &valid_rects[i], dest_rect))
+            {
+              continue;
+            }
+
+          gimp_gegl_buffer_copy (cache,       &valid_rect, GEGL_ABYSS_NONE,
+                                 dest_buffer, &valid_rect);
+
+          cairo_region_subtract_rectangle (region,
+                                           (cairo_rectangle_int_t *)
+                                           &valid_rect);
+
+          done_pixels += valid_rect.width * valid_rect.height;
+
+          if (progress)
+            {
+              gimp_progress_set_value (progress,
+                                       (gdouble) done_pixels /
+                                       (gdouble) all_pixels);
+            }
+        }
+    }
+
   gegl = gegl_node_new ();
 
   if (! gegl_node_get_parent (operation))
@@ -189,72 +255,6 @@ gimp_gegl_apply_cached_operation (GeglBuffer          *src_buffer,
   gegl_node_connect_to (effect,    "output",
                         dest_node, "input");
 
-  if (progress)
-    {
-      if (gimp_progress_is_active (progress))
-        {
-          if (undo_desc)
-            gimp_progress_set_text_literal (progress, undo_desc);
-
-          progress_started = FALSE;
-          cancelable       = FALSE;
-        }
-      else
-        {
-          gimp_progress_start (progress, cancelable, "%s", undo_desc);
-
-          if (cancelable)
-            g_signal_connect (progress, "cancel",
-                              G_CALLBACK (gimp_gegl_apply_operation_cancel),
-                              &cancel);
-
-          progress_started = TRUE;
-        }
-    }
-  else
-    {
-      cancelable = FALSE;
-    }
-
-  gegl_buffer_freeze_changed (dest_buffer);
-
-  all_pixels  = dest_rect->width * dest_rect->height;
-  done_pixels = 0;
-
-  region = cairo_region_create_rectangle ((cairo_rectangle_int_t *) dest_rect);
-
-  if (cache)
-    {
-      gint i;
-
-      for (i = 0; i < n_valid_rects; i++)
-        {
-          GeglRectangle valid_rect;
-
-          if (! gegl_rectangle_intersect (&valid_rect,
-                                          &valid_rects[i], dest_rect))
-            {
-              continue;
-            }
-
-          gimp_gegl_buffer_copy (cache,       &valid_rect, GEGL_ABYSS_NONE,
-                                 dest_buffer, &valid_rect);
-
-          cairo_region_subtract_rectangle (region,
-                                           (cairo_rectangle_int_t *)
-                                           &valid_rect);
-
-          done_pixels += valid_rect.width * valid_rect.height;
-
-          if (progress)
-            {
-              gimp_progress_set_value (progress,
-                                       (gdouble) done_pixels /
-                                       (gdouble) all_pixels);
-            }
-        }
-    }
-
   iter = gimp_chunk_iterator_new (region);
 
   if (progress &&


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