From d8622989e315d468112ab693e746c6511dfab896 Mon Sep 17 00:00:00 2001 From: Ell Date: Sat, 7 Sep 2019 10:18:50 +0300 Subject: [PATCH] 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. (cherry picked from commit 184762cd81bc2d3df7f3c47fd654ef79a6d1bf63) --- 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 95921aac3e..52777f8536 100644 --- a/app/core/gimpgrouplayer.c +++ b/app/core/gimpgrouplayer.c @@ -1150,13 +1150,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);