From de6f78b058fca19df858ebf42341a83e28da107c Mon Sep 17 00:00:00 2001 From: Manolis Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Wed, 9 Dec 2020 18:07:12 +0200 Subject: [PATCH] Fix crash when importing an image file as a new frame --- src/Autoload/Global.gd | 8 ++++---- src/Autoload/OpenSave.gd | 4 ++++ src/UI/Timeline/AnimationTimeline.gd | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index 7f07aa262..8420dcde3 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -555,11 +555,11 @@ func update_recent_projects_submenu() -> void: recent_projects_submenu.add_item(project.get_file()) func use_osx_shortcuts() -> void: - var inputmap := InputMap - + var inputmap := InputMap + for action in inputmap.get_actions(): - var event : InputEvent = inputmap.get_action_list(action)[0] - + var event : InputEvent = inputmap.get_action_list(action)[0] + if event.control: event.control = false event.command = true diff --git a/src/Autoload/OpenSave.gd b/src/Autoload/OpenSave.gd index 474921f57..6b574bc4d 100644 --- a/src/Autoload/OpenSave.gd +++ b/src/Autoload/OpenSave.gd @@ -394,6 +394,7 @@ func open_image_as_new_frame(image : Image, layer_index := 0) -> void: var project = Global.current_project image.crop(project.size.x, project.size.y) var new_frames : Array = project.frames.duplicate() + var frame_duration : Array = Global.current_project.frame_duration.duplicate() var frame := Frame.new() for i in project.layers.size(): @@ -408,6 +409,7 @@ func open_image_as_new_frame(image : Image, layer_index := 0) -> void: frame.cels.append(Cel.new(empty_image, 1)) new_frames.append(frame) + frame_duration.insert(project.current_frame + 1, 1) project.undos += 1 project.undo_redo.create_action("Add Frame") @@ -417,10 +419,12 @@ func open_image_as_new_frame(image : Image, layer_index := 0) -> void: project.undo_redo.add_do_property(project, "frames", new_frames) project.undo_redo.add_do_property(project, "current_frame", new_frames.size() - 1) project.undo_redo.add_do_property(project, "current_layer", layer_index) + Global.current_project.undo_redo.add_do_property(Global.current_project, "frame_duration", frame_duration) # Add an 1 in the list of frame_duration project.undo_redo.add_undo_property(project, "frames", project.frames) project.undo_redo.add_undo_property(project, "current_frame", project.current_frame) project.undo_redo.add_undo_property(project, "current_layer", project.current_layer) + Global.current_project.undo_redo.add_undo_property(Global.current_project, "frame_duration", Global.current_project.frame_duration) project.undo_redo.commit_action() diff --git a/src/UI/Timeline/AnimationTimeline.gd b/src/UI/Timeline/AnimationTimeline.gd index af30948b9..2ff32db0f 100644 --- a/src/UI/Timeline/AnimationTimeline.gd +++ b/src/UI/Timeline/AnimationTimeline.gd @@ -50,7 +50,7 @@ func add_frame() -> void: Global.current_project.undo_redo.add_do_property(Global.current_project, "frames", new_frames) Global.current_project.undo_redo.add_do_property(Global.current_project, "current_frame", Global.current_project.current_frame + 1) Global.current_project.undo_redo.add_do_property(Global.current_project, "layers", new_layers) - Global.current_project.undo_redo.add_do_property(Global.current_project, "frame_duration", frame_duration) #Add a 1 in the list of frame_duration + Global.current_project.undo_redo.add_do_property(Global.current_project, "frame_duration", frame_duration) # Add an 1 in the list of frame_duration Global.current_project.undo_redo.add_undo_property(Global.current_project, "frames", Global.current_project.frames) Global.current_project.undo_redo.add_undo_property(Global.current_project, "current_frame", Global.current_project.current_frame )