From 387a333b9469fefdc072f2098343aad25de4420a Mon Sep 17 00:00:00 2001 From: Umang Kalra Date: Wed, 24 Nov 2021 23:55:25 +0530 Subject: [PATCH] Fixes variable/singal nodes not renaming in visualscript editor --- .../editor/visual_script_editor.cpp | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/modules/visual_script/editor/visual_script_editor.cpp b/modules/visual_script/editor/visual_script_editor.cpp index e8b25b58b6b..13dd1f7bc7f 100644 --- a/modules/visual_script/editor/visual_script_editor.cpp +++ b/modules/visual_script/editor/visual_script_editor.cpp @@ -1262,6 +1262,23 @@ void VisualScriptEditor::_member_edited() { undo_redo->create_action(TTR("Rename Variable")); undo_redo->add_do_method(script.ptr(), "rename_variable", name, new_name); undo_redo->add_undo_method(script.ptr(), "rename_variable", new_name, name); + + // Also fix all variable setter & getter calls + List lst; + script->get_node_list(&lst); + for (int &P : lst) { + Ref pset = script->get_node(P); + if (pset.is_valid() && pset->get_property() == name) { + undo_redo->add_do_method(pset.ptr(), "set_property", new_name); + undo_redo->add_undo_method(pset.ptr(), "set_property", name); + } + Ref pget = script->get_node(P); + if (pget.is_valid() && pget->get_property() == name) { + undo_redo->add_do_method(pget.ptr(), "set_property", new_name); + undo_redo->add_undo_method(pget.ptr(), "set_property", name); + } + } + undo_redo->add_do_method(this, "_update_members"); undo_redo->add_undo_method(this, "_update_members"); undo_redo->add_do_method(this, "_update_graph"); @@ -1278,6 +1295,18 @@ void VisualScriptEditor::_member_edited() { undo_redo->create_action(TTR("Rename Signal")); undo_redo->add_do_method(script.ptr(), "rename_custom_signal", name, new_name); undo_redo->add_undo_method(script.ptr(), "rename_custom_signal", new_name, name); + + // Also fix all signal emitting nodes + List lst; + script->get_node_list(&lst); + for (int &P : lst) { + Ref psig = script->get_node(P); + if (psig.is_valid() && psig->get_signal() == name) { + undo_redo->add_do_method(psig.ptr(), "set_signal", new_name); + undo_redo->add_undo_method(psig.ptr(), "set_signal", name); + } + } + undo_redo->add_do_method(this, "_update_members"); undo_redo->add_undo_method(this, "_update_members"); undo_redo->add_do_method(this, "emit_signal", "edited_script_changed");