Warning dialog is now shown if trying to set Node name to empty string

If the user tried to change a Node name to an empty string in the Scene
Tree Editor an error would be returned to console, now a warning dialog
is shown with a clear message
This commit is contained in:
Silvano Cerza 2018-10-29 14:47:53 +01:00
parent bfd1f09ac5
commit 839f3d5eeb
1 changed files with 7 additions and 0 deletions

View File

@ -665,6 +665,13 @@ void SceneTreeEditor::_renamed() {
Node *n = get_node(np);
ERR_FAIL_COND(!n);
// Empty node names are not allowed, so resets it to previous text and show warning
if (which->get_text(0).strip_edges().empty()) {
which->set_text(0, n->get_name());
EditorNode::get_singleton()->show_warning(TTR("No name provided"));
return;
}
String new_name = which->get_text(0);
if (!Node::_validate_node_name(new_name)) {