Fix node renaming bug when using the '.' character
Fixed by making '.' (and '/') illegal character in node names when adding via the rename feature.
This commit is contained in:
parent
61c4c5795f
commit
1d3fa162c8
1 changed files with 12 additions and 4 deletions
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue