[gimp] app: fix empty mask when duplicating a group layer



commit 184762cd81bc2d3df7f3c47fd654ef79a6d1bf63
Author: Ell <ell_se yahoo com>
Date:   Sat Sep 7 10:18:50 2019 +0300

    app: fix empty mask when duplicating a group layer
    
    In gimp_group_layer_mask_changed(), avoid recalculating the group's
    bounding box if it hasn't been calculated yet, since, not only is
    this unnecessary in this case, but it causes the group's mask to
    be erroneously clipped upon duplication, when set by
    gimp_layer_duplicate() while the group is still empty.

 app/core/gimpgrouplayer.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/app/core/gimpgrouplayer.c b/app/core/gimpgrouplayer.c
index 6fcea9cba4..17fd4ca03f 100644
--- a/app/core/gimpgrouplayer.c
+++ b/app/core/gimpgrouplayer.c
@@ -1154,13 +1154,21 @@ gimp_group_layer_excludes_backdrop_changed (GimpLayer *layer)
 static void
 gimp_group_layer_mask_changed (GimpLayer *layer)
 {
-  GimpGroupLayer *group = GIMP_GROUP_LAYER (layer);
+  GimpGroupLayer        *group = GIMP_GROUP_LAYER (layer);
+  GimpGroupLayerPrivate *private = GET_PRIVATE (layer);
 
   g_warn_if_fail (GET_PRIVATE (layer)->suspend_mask == 0);
 
   gimp_layer_update_effective_mode (layer);
 
-  gimp_group_layer_update_size (group);
+  /* if we've already computed a bounding box, update it now, since the mask
+   * limits the bounding box to the group's size.  if we haven't computed a
+   * bounding box yet we can skip this, and, in fact, we have to, or else the
+   * mask will be improperly clipped when the group is duplicated, discarding
+   * its data.
+   */
+  if (! gegl_rectangle_is_empty (&private->bounding_box))
+    gimp_group_layer_update (group);
 
   if (GIMP_LAYER_CLASS (parent_class)->mask_changed)
     GIMP_LAYER_CLASS (parent_class)->mask_changed (layer);


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