Bug 795410 - Deleting a layer group and then undoing the deletion ...

Desktop / GNOME / GIMP - Ell [yahoo.com] - 22 April 2018 08:05 UTC

... raises a CRITICAL

gimp_item_{start,end}_move() currently serves two different purposes: It is used by GimpLayer to suspend/resume mask resizing of the layer's ancestors; this is necessary whenever an operation on a layer might affect the size of its ancestors. It is also used by GimpGroupLayer to suspend/resume its own mask resizing; this, on the other hand, is only necessary before applying one of the transformation functions to the group, so that mask modification is handled by GimpLayer. In other words, the effects of gimp_item_{start,end}_move() on group layers are only necessary in a subset of the cases in which these functions are used.

While in itself this isn't a problem, it does cause issues when removing a group layer: gimp_image_remove_layer() calls gimp_item_start_move() before removing the layer, and gimp_item_end_move() afterwards. While the former function is called while the layer is still attached to the image, the latter function is called after the layer is no longer attached. Since GimpGroupLayer pushes an undo step in response to these calls, only the call to start_move() results in an undo step, while the call to end_move() doesn't, resulting in an unbalanced GIMP_UNDO_GROUP_LAYER_START_MOVE undo step on the stack. This causes problems when undoing the operation.

Add gimp_item_{start,end}_transform() functions, and corresponding GimpItem::{start,end}_transform() virtual functions, which are more specialized versions of gimp_item_{start,end}_move(), which should be used instead of the former before/after transforming an item; in other cases, such as when removing ot reordering an item, gimp_item_{start,end}_move() should still be used. The default implementation of GimpItem::{start,end}_transform() calls gimp_item_{start,end}_move(), respectively, so subclasses that override these functions don't have to do that themselves.

In GimpGroupLayer, override GimpItem::{start,end}_transform(), instead of GimpItem::{start,end}_move(), for the same purpose of suspending mask resize. This avoids these functions from being called when removing a layer group, fixing the bug.

37742a9fee Bug 795410 - Deleting a layer group and then undoing the deletion ...
app/core/core-enums.c | 8 ++---
app/core/core-enums.h | 4 +--
app/core/gimpgrouplayer.c | 66 +++++++++++++++++++--------------------
app/core/gimpgrouplayer.h | 4 +--
app/core/gimpgrouplayerundo.c | 20 ++++++------
app/core/gimpimage-item-list.c | 16 +++++-----
app/core/gimpimage-resize.c | 4 +++
app/core/gimpimage-undo-push.c | 16 +++++-----
app/core/gimpimage-undo-push.h | 4 +--
app/core/gimpitem.c | 70 ++++++++++++++++++++++++++++++++++++------
app/core/gimpitem.h | 9 ++++++
11 files changed, 140 insertions(+), 81 deletions(-)

Upstream: git.gnome.org


  • Share