diff --git a/src/UI/Dialogs/ImageEffects/FlipImageDialog.gd b/src/UI/Dialogs/ImageEffects/FlipImageDialog.gd index b33944a62..a086e8903 100644 --- a/src/UI/Dialogs/ImageEffects/FlipImageDialog.gd +++ b/src/UI/Dialogs/ImageEffects/FlipImageDialog.gd @@ -51,37 +51,34 @@ func _commit_undo(action: String, undo_data: Dictionary, project: Project) -> vo var redo_data := _get_undo_data(project) project.undos += 1 project.undo_redo.create_action(action) - project.undo_redo.add_do_property(project, "selection_map", redo_data["selection_map"]) - project.undo_redo.add_do_property(project, "selection_offset", redo_data["outline_offset"]) - project.undo_redo.add_undo_property(project, "selection_map", undo_data["selection_map"]) - project.undo_redo.add_undo_property(project, "selection_offset", undo_data["outline_offset"]) + if redo_data.has("selection_map"): + project.undo_redo.add_do_property(project, "selection_map", redo_data["selection_map"]) + project.undo_redo.add_do_property(project, "selection_offset", redo_data["outline_offset"]) + project.undo_redo.add_undo_property(project, "selection_map", undo_data["selection_map"]) + project.undo_redo.add_undo_property( + project, "selection_offset", undo_data["outline_offset"] + ) + project.undo_redo.add_do_method(project.selection_map_changed) + project.undo_redo.add_undo_method(project.selection_map_changed) - for image in redo_data: - if not image is Image: - continue - project.undo_redo.add_do_property(image, "data", redo_data[image]) - for image in undo_data: - if not image is Image: - continue - project.undo_redo.add_undo_property(image, "data", undo_data[image]) + Global.undo_redo_compress_images(redo_data, undo_data, project) project.undo_redo.add_do_method(Global.undo_or_redo.bind(false, -1, -1, project)) - project.undo_redo.add_do_method(project.selection_map_changed) project.undo_redo.add_undo_method(Global.undo_or_redo.bind(true, -1, -1, project)) - project.undo_redo.add_undo_method(project.selection_map_changed) project.undo_redo.commit_action() func _get_undo_data(project: Project) -> Dictionary: - var bitmap_image := SelectionMap.new() - bitmap_image.copy_from(project.selection_map) + var affect_selection := selection_checkbox.button_pressed and project.has_selection var data := {} - data["selection_map"] = bitmap_image - data["outline_offset"] = project.selection_offset + if affect_selection: + var bitmap_image := SelectionMap.new() + bitmap_image.copy_from(project.selection_map) + data["selection_map"] = bitmap_image + data["outline_offset"] = project.selection_offset var images := _get_selected_draw_images(project) for image in images: data[image] = image.data - return data