diff --git a/src/UI/Canvas/Canvas.gd b/src/UI/Canvas/Canvas.gd index 74e759149..99861b242 100644 --- a/src/UI/Canvas/Canvas.gd +++ b/src/UI/Canvas/Canvas.gd @@ -220,13 +220,15 @@ func handle_redo(_action : String, project : Project = Global.current_project, l func update_texture(layer_index : int, frame_index := -1, project : Project = Global.current_project) -> void: if frame_index == -1: frame_index = project.current_frame - var current_cel : Cel = project.frames[frame_index].cels[layer_index] - current_cel.image_texture.create_from_image(current_cel.image, 0) - if project == Global.current_project: - var frame_texture_rect : TextureRect - frame_texture_rect = Global.find_node_by_name(project.layers[layer_index].frame_container.get_child(frame_index), "CelTexture") - frame_texture_rect.texture = current_cel.image_texture + if frame_index < project.frames.size() and layer_index < project.layers.size(): + var current_cel : Cel = project.frames[frame_index].cels[layer_index] + current_cel.image_texture.create_from_image(current_cel.image, 0) + + if project == Global.current_project: + var frame_texture_rect : TextureRect + frame_texture_rect = Global.find_node_by_name(project.layers[layer_index].frame_container.get_child(frame_index), "CelTexture") + frame_texture_rect.texture = current_cel.image_texture func onion_skinning() -> void: diff --git a/src/UI/Canvas/Selection.gd b/src/UI/Canvas/Selection.gd index b3ba2ada4..9c337bddf 100644 --- a/src/UI/Canvas/Selection.gd +++ b/src/UI/Canvas/Selection.gd @@ -442,18 +442,19 @@ func transform_content_confirm() -> void: if !is_moving_content: return var project : Project = Global.current_project - var cel_image : Image = project.frames[project.current_frame].cels[project.current_layer].image - cel_image.blit_rect_mask(preview_image, preview_image, Rect2(Vector2.ZERO, project.selection_bitmap.get_size()), big_bounding_rectangle.position) - var selected_bitmap_copy = project.selection_bitmap.duplicate() - project.move_bitmap_values(selected_bitmap_copy) - project.selection_bitmap = selected_bitmap_copy + if project.current_frame < project.frames.size() and project.current_layer < project.layers.size(): + var cel_image : Image = project.frames[project.current_frame].cels[project.current_layer].image + cel_image.blit_rect_mask(preview_image, preview_image, Rect2(Vector2.ZERO, project.selection_bitmap.get_size()), big_bounding_rectangle.position) + var selected_bitmap_copy = project.selection_bitmap.duplicate() + project.move_bitmap_values(selected_bitmap_copy) + project.selection_bitmap = selected_bitmap_copy + commit_undo("Move Selection", undo_data) original_preview_image = Image.new() preview_image = Image.new() original_bitmap = BitMap.new() is_moving_content = false is_pasting = false - commit_undo("Move Selection", undo_data) update()