Skip to content

Commit

Permalink
Merge pull request #87967 from jsjtxietian/set_item_submenu
Browse files Browse the repository at this point in the history
Fix `set_item_submenu` infinite recursion crash
  • Loading branch information
akien-mga committed Feb 22, 2024
2 parents 150f002 + 3525972 commit a246a4b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions scene/gui/popup_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1808,6 +1808,11 @@ void PopupMenu::set_item_submenu(int p_idx, const String &p_submenu) {
return;
}

String submenu_name_safe = p_submenu.replace("@", "_"); // Allow special characters for auto-generated names.
if (submenu_name_safe.validate_node_name() != submenu_name_safe) {
ERR_FAIL_MSG(vformat("Invalid node name '%s' for a submenu, the following characters are not allowed:\n%s", p_submenu, String::get_invalid_node_name_characters(true)));
}

if (!global_menu_name.is_empty()) {
if (items[p_idx].submenu_bound) {
PopupMenu *pm = Object::cast_to<PopupMenu>(get_node_or_null(items[p_idx].submenu));
Expand Down

0 comments on commit a246a4b

Please sign in to comment.