You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-23 15:16:17 +00:00
Free submenu children when clearing PopupMenu
This commit is contained in:
@@ -192,8 +192,9 @@
|
|||||||
</method>
|
</method>
|
||||||
<method name="clear">
|
<method name="clear">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
|
<param index="0" name="free_submenus" type="bool" default="false" />
|
||||||
<description>
|
<description>
|
||||||
Removes all items from the [PopupMenu].
|
Removes all items from the [PopupMenu]. If [param free_submenus] is [code]true[/code], the submenu nodes are automatically freed.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_focused_item" qualifiers="const">
|
<method name="get_focused_item" qualifiers="const">
|
||||||
|
|||||||
@@ -184,3 +184,10 @@ Validate extension JSON: Error: Field 'classes/PhysicsServer3DRenderingServerHan
|
|||||||
Validate extension JSON: Error: Field 'classes/PhysicsServer3DRenderingServerHandler/methods/_set_normal/arguments/1': type changed value in new API, from "const void*" to "Vector3".
|
Validate extension JSON: Error: Field 'classes/PhysicsServer3DRenderingServerHandler/methods/_set_normal/arguments/1': type changed value in new API, from "const void*" to "Vector3".
|
||||||
|
|
||||||
Intentional compatibility breakage to be consistent with the new non-virtual set_vertex/set_normal.
|
Intentional compatibility breakage to be consistent with the new non-virtual set_vertex/set_normal.
|
||||||
|
|
||||||
|
|
||||||
|
GH-79965
|
||||||
|
--------
|
||||||
|
Validate extension JSON: JSON file: Field was added in a way that breaks compatibility 'classes/PopupMenu/methods/clear': arguments
|
||||||
|
|
||||||
|
Added optional argument. Compatibility method registered.
|
||||||
|
|||||||
@@ -31,16 +31,21 @@
|
|||||||
#ifndef DISABLE_DEPRECATED
|
#ifndef DISABLE_DEPRECATED
|
||||||
|
|
||||||
void PopupMenu::_add_shortcut_bind_compat_36493(const Ref<Shortcut> &p_shortcut, int p_id, bool p_global) {
|
void PopupMenu::_add_shortcut_bind_compat_36493(const Ref<Shortcut> &p_shortcut, int p_id, bool p_global) {
|
||||||
return add_shortcut(p_shortcut, p_id, p_global, false);
|
add_shortcut(p_shortcut, p_id, p_global, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::_add_icon_shortcut_bind_compat_36493(const Ref<Texture2D> &p_icon, const Ref<Shortcut> &p_shortcut, int p_id, bool p_global) {
|
void PopupMenu::_add_icon_shortcut_bind_compat_36493(const Ref<Texture2D> &p_icon, const Ref<Shortcut> &p_shortcut, int p_id, bool p_global) {
|
||||||
return add_icon_shortcut(p_icon, p_shortcut, p_id, p_global, false);
|
add_icon_shortcut(p_icon, p_shortcut, p_id, p_global, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PopupMenu::_clear_bind_compat_79965() {
|
||||||
|
clear(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::_bind_compatibility_methods() {
|
void PopupMenu::_bind_compatibility_methods() {
|
||||||
ClassDB::bind_compatibility_method(D_METHOD("add_shortcut", "shortcut", "id", "global"), &PopupMenu::_add_shortcut_bind_compat_36493, DEFVAL(-1), DEFVAL(false));
|
ClassDB::bind_compatibility_method(D_METHOD("add_shortcut", "shortcut", "id", "global"), &PopupMenu::_add_shortcut_bind_compat_36493, DEFVAL(-1), DEFVAL(false));
|
||||||
ClassDB::bind_compatibility_method(D_METHOD("add_icon_shortcut", "texture", "shortcut", "id", "global"), &PopupMenu::_add_icon_shortcut_bind_compat_36493, DEFVAL(-1), DEFVAL(false));
|
ClassDB::bind_compatibility_method(D_METHOD("add_icon_shortcut", "texture", "shortcut", "id", "global"), &PopupMenu::_add_icon_shortcut_bind_compat_36493, DEFVAL(-1), DEFVAL(false));
|
||||||
|
ClassDB::bind_compatibility_method(D_METHOD("clear"), &PopupMenu::_clear_bind_compat_79965);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1908,10 +1908,18 @@ void PopupMenu::add_separator(const String &p_text, int p_id) {
|
|||||||
_menu_changed();
|
_menu_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::clear() {
|
void PopupMenu::clear(bool p_free_submenus) {
|
||||||
for (int i = 0; i < items.size(); i++) {
|
for (const Item &I : items) {
|
||||||
if (items[i].shortcut.is_valid()) {
|
if (I.shortcut.is_valid()) {
|
||||||
_unref_shortcut(items[i].shortcut);
|
_unref_shortcut(I.shortcut);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p_free_submenus && !I.submenu.is_empty()) {
|
||||||
|
Node *submenu = get_node_or_null(I.submenu);
|
||||||
|
if (submenu) {
|
||||||
|
remove_child(submenu);
|
||||||
|
submenu->queue_free();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
items.clear();
|
items.clear();
|
||||||
@@ -2236,7 +2244,7 @@ void PopupMenu::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("remove_item", "index"), &PopupMenu::remove_item);
|
ClassDB::bind_method(D_METHOD("remove_item", "index"), &PopupMenu::remove_item);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("add_separator", "label", "id"), &PopupMenu::add_separator, DEFVAL(String()), DEFVAL(-1));
|
ClassDB::bind_method(D_METHOD("add_separator", "label", "id"), &PopupMenu::add_separator, DEFVAL(String()), DEFVAL(-1));
|
||||||
ClassDB::bind_method(D_METHOD("clear"), &PopupMenu::clear);
|
ClassDB::bind_method(D_METHOD("clear", "free_submenus"), &PopupMenu::clear, DEFVAL(false));
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_hide_on_item_selection", "enable"), &PopupMenu::set_hide_on_item_selection);
|
ClassDB::bind_method(D_METHOD("set_hide_on_item_selection", "enable"), &PopupMenu::set_hide_on_item_selection);
|
||||||
ClassDB::bind_method(D_METHOD("is_hide_on_item_selection"), &PopupMenu::is_hide_on_item_selection);
|
ClassDB::bind_method(D_METHOD("is_hide_on_item_selection"), &PopupMenu::is_hide_on_item_selection);
|
||||||
|
|||||||
@@ -202,6 +202,7 @@ protected:
|
|||||||
#ifndef DISABLE_DEPRECATED
|
#ifndef DISABLE_DEPRECATED
|
||||||
void _add_shortcut_bind_compat_36493(const Ref<Shortcut> &p_shortcut, int p_id = -1, bool p_global = false);
|
void _add_shortcut_bind_compat_36493(const Ref<Shortcut> &p_shortcut, int p_id = -1, bool p_global = false);
|
||||||
void _add_icon_shortcut_bind_compat_36493(const Ref<Texture2D> &p_icon, const Ref<Shortcut> &p_shortcut, int p_id = -1, bool p_global = false);
|
void _add_icon_shortcut_bind_compat_36493(const Ref<Texture2D> &p_icon, const Ref<Shortcut> &p_shortcut, int p_id = -1, bool p_global = false);
|
||||||
|
void _clear_bind_compat_79965();
|
||||||
static void _bind_compatibility_methods();
|
static void _bind_compatibility_methods();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -296,7 +297,7 @@ public:
|
|||||||
|
|
||||||
void add_separator(const String &p_text = String(), int p_id = -1);
|
void add_separator(const String &p_text = String(), int p_id = -1);
|
||||||
|
|
||||||
void clear();
|
void clear(bool p_free_submenus = true);
|
||||||
|
|
||||||
virtual String get_tooltip(const Point2 &p_pos) const;
|
virtual String get_tooltip(const Point2 &p_pos) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user