Trims user provided group name

This commit is contained in:
Haoyu Qiu 2020-01-09 14:16:07 +08:00
parent 4b83bbd463
commit 715c0f9dfd
1 changed files with 7 additions and 5 deletions

View File

@ -215,7 +215,7 @@ void GroupDialog::_group_renamed() {
return;
}
String name = renamed_group->get_text(0).strip_edges();
const String name = renamed_group->get_text(0).strip_edges();
for (TreeItem *E = groups_root->get_children(); E; E = E->get_next()) {
if (E != renamed_group && E->get_text(0) == name) {
renamed_group->set_text(0, selected_group);
@ -232,6 +232,8 @@ void GroupDialog::_group_renamed() {
return;
}
renamed_group->set_text(0, name); // Spaces trimmed.
undo_redo->create_action(TTR("Rename Group"));
List<Node *> nodes;
@ -254,8 +256,8 @@ void GroupDialog::_group_renamed() {
undo_redo->add_undo_method(this, "_delete_group_item", selected_group);
}
undo_redo->add_do_method(this, "_rename_group_item", selected_group, renamed_group->get_text(0));
undo_redo->add_undo_method(this, "_rename_group_item", renamed_group->get_text(0), selected_group);
undo_redo->add_do_method(this, "_rename_group_item", selected_group, name);
undo_redo->add_undo_method(this, "_rename_group_item", name, selected_group);
undo_redo->add_do_method(this, "_group_selected");
undo_redo->add_undo_method(this, "_group_selected");
undo_redo->add_do_method(this, "emit_signal", "group_edited");
@ -550,8 +552,8 @@ void GroupsEditor::_add_group(const String &p_group) {
if (!node)
return;
String name = group_name->get_text();
if (name.strip_edges() == "")
const String name = group_name->get_text().strip_edges();
if (name.empty())
return;
if (node->is_in_group(name))