From fab75bce3fcf6355accdb0e2ef23aef45c996b61 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 8 Aug 2017 11:32:09 -0300 Subject: [PATCH] Properly rename visual script functions, fixed #6076 --- modules/visual_script/visual_script_editor.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index a71d38f7a0a..8912227692c 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -869,15 +869,27 @@ void VisualScriptEditor::_member_edited() { } selected = new_name; - _update_graph(); - + int node_id = script->get_function_node_id(name); + Ref func; + if (script->has_node(name, node_id)) { + func = script->get_node(name, node_id); + } undo_redo->create_action(TTR("Rename Function")); undo_redo->add_do_method(script.ptr(), "rename_function", name, new_name); undo_redo->add_undo_method(script.ptr(), "rename_function", new_name, name); + if (func.is_valid()) { + + undo_redo->add_do_method(func.ptr(), "set_name", new_name); + undo_redo->add_undo_method(func.ptr(), "set_name", 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"); + undo_redo->add_undo_method(this, "_update_graph"); undo_redo->commit_action(); + // _update_graph(); + return; //or crash because it will become invalid }