From be093f3490a9ef3b9afc25715c1122397c19eae0 Mon Sep 17 00:00:00 2001 From: Variable <77773850+Variable-ind@users.noreply.github.com> Date: Mon, 9 Oct 2023 14:55:17 +0500 Subject: [PATCH] [0.x] Fix undo/redo history not working when the tool changes (#916) * remove_undo_redo_draw_op from Draw.gd * shifted undo_redo_draw_op to Global.gd --- src/Autoload/Global.gd | 4 ++++ src/Tools/Draw.gd | 8 ++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index 116c46899..2216f7a90 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -617,3 +617,7 @@ func convert_dictionary_values(dict: Dictionary) -> void: dict[key] = str2var("Vector2" + dict[key]) elif "size" in key or "center_offset" in key: # Convert a String to a Vector3 dict[key] = str2var("Vector3" + dict[key]) + + +func undo_redo_draw_op(image: Object, compressed_image_data: Dictionary, buffer_size: int) -> void: + image["data"]["data"] = compressed_image_data["data"].decompress(buffer_size) diff --git a/src/Tools/Draw.gd b/src/Tools/Draw.gd index 6a9b0b124..9311e4a8c 100644 --- a/src/Tools/Draw.gd +++ b/src/Tools/Draw.gd @@ -213,7 +213,7 @@ func commit_undo() -> void: var buffer_size = compressed_data["data"].size() compressed_data["data"] = compressed_data["data"].compress() project.undo_redo.add_do_method( - self, "undo_redo_draw_op", image, compressed_data, buffer_size + Global, "undo_redo_draw_op", image, compressed_data, buffer_size ) image.unlock() for image in _undo_data: @@ -221,7 +221,7 @@ func commit_undo() -> void: var buffer_size = compressed_data["data"].size() compressed_data["data"] = compressed_data["data"].compress() project.undo_redo.add_undo_method( - self, "undo_redo_draw_op", image, compressed_data, buffer_size + Global, "undo_redo_draw_op", image, compressed_data, buffer_size ) project.undo_redo.add_do_method(Global, "undo_or_redo", false, frame, layer) project.undo_redo.add_undo_method(Global, "undo_or_redo", true, frame, layer) @@ -230,10 +230,6 @@ func commit_undo() -> void: _undo_data.clear() -func undo_redo_draw_op(image: Object, compressed_image_data: Dictionary, buffer_size: int) -> void: - image["data"]["data"] = compressed_image_data["data"].decompress(buffer_size) - - func draw_tool(position: Vector2) -> void: if Global.mirror_view: # Even brushes are not perfectly centred and are offsetted by 1 px so we add it