summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-08-08 11:32:09 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-08-08 11:32:09 -0300
commitfab75bce3fcf6355accdb0e2ef23aef45c996b61 (patch)
treec3ad4c45e0bd6fd621c57ded6870b589644c4095 /modules
parentdb7f49183357c282e267c0743411505eb61f1c6f (diff)
Properly rename visual script functions, fixed #6076
Diffstat (limited to 'modules')
-rw-r--r--modules/visual_script/visual_script_editor.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index a71d38f7a0..8912227692 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<VisualScriptFunction> 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
}