Skip to content

Bug in undo snapshot logic when handling reversible actions

Natalie Mona Matthews requested to merge nataliemona/digikam:master into master

It looks like there is a mishandled case when determining whether to create a snapshot in undoStep.

The previously written comment says:

// Undoing an irreversible with next redo reversible:
// Here, no snapshot was made in addAction, but we need it now

However, this else statement captures both reversible and irreversible actions being undone with the latest redo action being reversible. This means that when undoing reversible actions, unnecessary snapshots are taken.

Since redoing a reversible action does not restore a snapshot (instead it simply re-applies the reversible filter), these snapshots are unused.

Correct snapshot logic for undoStep:

  1. Don't snapshot if the action being undone is reversible.
  2. If the action being undone is irreversible, snapshot if redo actions is empty or if the latest redo action was reversible. This covers the two cases in which a snapshot wouldn't have been already taken.

IMG_0027

Merge request reports