Merge pull request #2767 from akien-mga/PR-node-rename-problem2

Fix node renaming bug when using the '.' character
This commit is contained in:
Juan Linietsky 2015-11-18 18:44:11 -03:00
commit 9833fc21e6
1 changed files with 12 additions and 4 deletions

View File

@ -655,14 +655,22 @@ void SceneTreeEditor::_renamed() {
Node *n=get_node(np); Node *n=get_node(np);
ERR_FAIL_COND(!n); ERR_FAIL_COND(!n);
String new_name=which->get_text(0);
if (new_name.find(".") != -1 || new_name.find("/") != -1) {
error->set_text("Invalid node name, the following characters are not allowed:\n \".\", \"/\"");
error->popup_centered_minsize();
new_name=n->get_name();
}
if (!undo_redo) { if (!undo_redo) {
n->set_name( which->get_text(0) ); n->set_name( new_name );
which->set_metadata(0,n->get_path()); which->set_metadata(0,n->get_path());
emit_signal("node_renamed"); emit_signal("node_renamed");
} else { } else {
undo_redo->create_action("Rename Node"); undo_redo->create_action("Rename Node");
emit_signal("node_prerename",n,which->get_text(0)); emit_signal("node_prerename",n,new_name);
undo_redo->add_do_method(this,"_rename_node",n->get_instance_ID(),which->get_text(0)); undo_redo->add_do_method(this,"_rename_node",n->get_instance_ID(),new_name);
undo_redo->add_undo_method(this,"_rename_node",n->get_instance_ID(),n->get_name()); undo_redo->add_undo_method(this,"_rename_node",n->get_instance_ID(),n->get_name());
undo_redo->commit_action(); undo_redo->commit_action();
} }