Merge pull request #34981 from timothyqiu/trim-group-name

Trims user provided group name
This commit is contained in:
Rémi Verschelde 2020-01-10 09:37:39 +01:00 committed by GitHub
commit 65446a1303
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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))