pencil2d / pencil

Pencil2D is an easy, intuitive tool to make 2D hand-drawn animations. Pencil2D is open source and cross-platform.
http://pencil2d.org
GNU General Public License v2.0
1.47k stars 273 forks source link

Undo frame deletion double undo/crash #1557

Closed scribblemaniac closed 3 years ago

scribblemaniac commented 3 years ago

Issue Summary

Undoing a frame deletion can cause two actions to be undone, or a crash in some situations. This is likely the same issue as #843, although the steps to reproduce are more involved.

Steps to reproduce

  1. Create a new project.
  2. Create a layer with at least two keyframes.
  3. Delete the first keyframe. If you are using a bitmap layer, the first keyframe must be at a position > 1.
  4. Undo the frame deletion. This will undo the frame deletion and the action before that, or it will crash if no other undoable actions were performed.

System Information

Developer Notes

This crash is happening when Editor::backup is called before reverting the deletion. In that function it uses getLast*ImageAtFrame, which returns null if there isn't a previous frame. If it's null, the backup is skipped, however Editor::undo always decrements mBackupIndex whether or not the backup was successful. Thus it goes back two actions instead of one, or causes an out of bounds exception if it goes below 0.

Jose-Moreno commented 3 years ago

@scribblemaniac Hi. Since this issue has been closed, just to make sure, when you're free can you check if the merged fix solves your original issue with this ticket? Thanks!

scribblemaniac commented 3 years ago

Can confirm this has been fixed.

Jose-Moreno commented 3 years ago

@scribblemaniac Excellent thanks a lot for testing! 🙇