Browse Source

Merge pull request #57832 from Sauermann/fix-id-creation

Rémi Verschelde 3 years ago
parent
commit
a4759e375a
1 changed files with 3 additions and 3 deletions
  1. 3 3
      scene/gui/popup_menu.cpp

+ 3 - 3
scene/gui/popup_menu.cpp

@@ -844,7 +844,7 @@ void PopupMenu::_notification(int p_what) {
 #define ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel) \
 #define ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel) \
 	item.text = p_label;                              \
 	item.text = p_label;                              \
 	item.xl_text = atr(p_label);                      \
 	item.xl_text = atr(p_label);                      \
-	item.id = p_id == -1 ? items.size() - 1 : p_id;   \
+	item.id = p_id == -1 ? items.size() : p_id;       \
 	item.accel = p_accel;
 	item.accel = p_accel;
 
 
 void PopupMenu::add_item(const String &p_label, int p_id, Key p_accel) {
 void PopupMenu::add_item(const String &p_label, int p_id, Key p_accel) {
@@ -926,7 +926,7 @@ void PopupMenu::add_multistate_item(const String &p_label, int p_max_states, int
 	_ref_shortcut(p_shortcut);                                                         \
 	_ref_shortcut(p_shortcut);                                                         \
 	item.text = p_shortcut->get_name();                                                \
 	item.text = p_shortcut->get_name();                                                \
 	item.xl_text = atr(item.text);                                                     \
 	item.xl_text = atr(item.text);                                                     \
-	item.id = p_id == -1 ? items.size() - 1 : p_id;                                    \
+	item.id = p_id == -1 ? items.size() : p_id;                                        \
 	item.shortcut = p_shortcut;                                                        \
 	item.shortcut = p_shortcut;                                                        \
 	item.shortcut_is_global = p_global;
 	item.shortcut_is_global = p_global;
 
 
@@ -995,7 +995,7 @@ void PopupMenu::add_submenu_item(const String &p_label, const String &p_submenu,
 	Item item;
 	Item item;
 	item.text = p_label;
 	item.text = p_label;
 	item.xl_text = atr(p_label);
 	item.xl_text = atr(p_label);
-	item.id = p_id == -1 ? items.size() - 1 : p_id;
+	item.id = p_id == -1 ? items.size() : p_id;
 	item.submenu = p_submenu;
 	item.submenu = p_submenu;
 	items.push_back(item);
 	items.push_back(item);
 	_shape_item(items.size() - 1);
 	_shape_item(items.size() - 1);