app: avoid deleting empty layer groups when downscaling image

When dowscaling an image (or a layer group), empty layer groups
can be discarded as a result of their new dimensions being too
small, since we're calculating their new dimensions according to
their fake 1x1 dimensions.  However, these dimensions are purely an
implementation detail and shouldn't affect the result, and neither
do we show a warning for them.

Instead, simply avoid discarding empty layer groups.

(cherry picked from commit b99a2631ef)
This commit is contained in:
Ell
2020-01-21 20:01:20 +02:00
parent 13bc82e0ff
commit 4f9c3f2a6a

View File

@ -31,6 +31,7 @@
#include "gimp.h"
#include "gimp-parasites.h"
#include "gimpchannel.h"
#include "gimpcontainer.h"
#include "gimpidtable.h"
#include "gimpimage.h"
#include "gimpimage-undo.h"
@ -1456,6 +1457,7 @@ gimp_item_scale_by_factors_with_origin (GimpItem *item,
GimpProgress *progress)
{
GimpItemPrivate *private;
GimpContainer *children;
gint new_width, new_height;
gint new_offset_x, new_offset_y;
@ -1471,6 +1473,12 @@ gimp_item_scale_by_factors_with_origin (GimpItem *item,
return FALSE;
}
children = gimp_viewable_get_children (GIMP_VIEWABLE (item));
/* avoid discarding empty layer groups */
if (children && gimp_container_is_empty (children))
return TRUE;
new_offset_x = SIGNED_ROUND (w_factor * (private->offset_x - origin_x));
new_offset_y = SIGNED_ROUND (h_factor * (private->offset_y - origin_y));
new_width = SIGNED_ROUND (w_factor * (private->offset_x - origin_x +