diff --git a/editor/gui/editor_file_dialog.h b/editor/gui/editor_file_dialog.h index 7d6fa19a443f..6272e27f8260 100644 --- a/editor/gui/editor_file_dialog.h +++ b/editor/gui/editor_file_dialog.h @@ -268,7 +268,7 @@ class EditorFileDialog : public ConfirmationDialog { void _notification(int p_what); bool _set(const StringName &p_name, const Variant &p_value) { return property_helper.property_set_value(p_name, p_value); } bool _get(const StringName &p_name, Variant &r_ret) const { return property_helper.property_get_value(p_name, r_ret); } - void _get_property_list(List *p_list) const { property_helper.get_property_list(p_list, options.size()); } + void _get_property_list(List *p_list) const { property_helper.get_property_list(p_list); } bool _property_can_revert(const StringName &p_name) const { return property_helper.property_can_revert(p_name); } bool _property_get_revert(const StringName &p_name, Variant &r_property) const { return property_helper.property_get_revert(p_name, r_property); } static void _bind_methods(); diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index f7d672620d31..d1f1c97ca2ea 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -722,7 +722,7 @@ bool TileMap::_get(const StringName &p_name, Variant &r_ret) const { void TileMap::_get_property_list(List *p_list) const { p_list->push_back(PropertyInfo(Variant::INT, "format", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL)); - property_helper.get_property_list(p_list, layers.size()); + property_helper.get_property_list(p_list); } Vector2 TileMap::map_to_local(const Vector2i &p_pos) const { diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h index 4236f0a56b0a..9680157f0a41 100644 --- a/scene/gui/file_dialog.h +++ b/scene/gui/file_dialog.h @@ -194,7 +194,7 @@ class FileDialog : public ConfirmationDialog { void _notification(int p_what); bool _set(const StringName &p_name, const Variant &p_value) { return property_helper.property_set_value(p_name, p_value); } bool _get(const StringName &p_name, Variant &r_ret) const { return property_helper.property_get_value(p_name, r_ret); } - void _get_property_list(List *p_list) const { property_helper.get_property_list(p_list, options.size()); } + void _get_property_list(List *p_list) const { property_helper.get_property_list(p_list); } bool _property_can_revert(const StringName &p_name) const { return property_helper.property_can_revert(p_name); } bool _property_get_revert(const StringName &p_name, Variant &r_property) const { return property_helper.property_get_revert(p_name, r_property); } static void _bind_methods(); diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h index 4c035ee4e64e..9a57b9d8fe49 100644 --- a/scene/gui/item_list.h +++ b/scene/gui/item_list.h @@ -162,7 +162,7 @@ class ItemList : public Control { void _notification(int p_what); bool _set(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const { return property_helper.property_get_value(p_name, r_ret); } - void _get_property_list(List *p_list) const { property_helper.get_property_list(p_list, items.size()); } + void _get_property_list(List *p_list) const { property_helper.get_property_list(p_list); } bool _property_can_revert(const StringName &p_name) const { return property_helper.property_can_revert(p_name); } bool _property_get_revert(const StringName &p_name, Variant &r_property) const { return property_helper.property_get_revert(p_name, r_property); } static void _bind_methods(); diff --git a/scene/gui/menu_button.h b/scene/gui/menu_button.h index 2bd577ddd0c2..5a74d61091c7 100644 --- a/scene/gui/menu_button.h +++ b/scene/gui/menu_button.h @@ -52,7 +52,7 @@ class MenuButton : public Button { void _notification(int p_what); bool _set(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const; - void _get_property_list(List *p_list) const { property_helper.get_property_list(p_list, popup->get_item_count()); } + void _get_property_list(List *p_list) const { property_helper.get_property_list(p_list); } bool _property_can_revert(const StringName &p_name) const { return property_helper.property_can_revert(p_name); } bool _property_get_revert(const StringName &p_name, Variant &r_property) const { return property_helper.property_get_revert(p_name, r_property); } static void _bind_methods(); diff --git a/scene/gui/option_button.h b/scene/gui/option_button.h index 4b5164161ae7..351df9a74977 100644 --- a/scene/gui/option_button.h +++ b/scene/gui/option_button.h @@ -84,7 +84,7 @@ class OptionButton : public Button { void _notification(int p_what); bool _set(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const { return property_helper.property_get_value(p_name, r_ret); } - void _get_property_list(List *p_list) const { property_helper.get_property_list(p_list, popup->get_item_count()); } + void _get_property_list(List *p_list) const { property_helper.get_property_list(p_list); } bool _property_can_revert(const StringName &p_name) const { return property_helper.property_can_revert(p_name); } bool _property_get_revert(const StringName &p_name, Variant &r_property) const { return property_helper.property_get_revert(p_name, r_property); } void _validate_property(PropertyInfo &p_property) const; diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h index 832c1bcc8be5..c6eef03aca39 100644 --- a/scene/gui/popup_menu.h +++ b/scene/gui/popup_menu.h @@ -218,7 +218,7 @@ class PopupMenu : public Popup { void _notification(int p_what); bool _set(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const { return property_helper.property_get_value(p_name, r_ret); } - void _get_property_list(List *p_list) const { property_helper.get_property_list(p_list, items.size()); } + void _get_property_list(List *p_list) const { property_helper.get_property_list(p_list); } bool _property_can_revert(const StringName &p_name) const { return property_helper.property_can_revert(p_name); } bool _property_get_revert(const StringName &p_name, Variant &r_property) const { return property_helper.property_get_revert(p_name, r_property); } static void _bind_methods(); diff --git a/scene/gui/tab_bar.h b/scene/gui/tab_bar.h index 52f1da5ec871..d62b39ae16fd 100644 --- a/scene/gui/tab_bar.h +++ b/scene/gui/tab_bar.h @@ -175,7 +175,7 @@ class TabBar : public Control { bool _set(const StringName &p_name, const Variant &p_value) { return property_helper.property_set_value(p_name, p_value); } bool _get(const StringName &p_name, Variant &r_ret) const { return property_helper.property_get_value(p_name, r_ret); } - void _get_property_list(List *p_list) const { property_helper.get_property_list(p_list, tabs.size()); } + void _get_property_list(List *p_list) const { property_helper.get_property_list(p_list); } bool _property_can_revert(const StringName &p_name) const { return property_helper.property_can_revert(p_name); } bool _property_get_revert(const StringName &p_name, Variant &r_property) const { return property_helper.property_get_revert(p_name, r_property); } void _notification(int p_what); diff --git a/scene/property_list_helper.cpp b/scene/property_list_helper.cpp index 152ecaf89db6..ce258ee8c3e6 100644 --- a/scene/property_list_helper.cpp +++ b/scene/property_list_helper.cpp @@ -122,8 +122,9 @@ bool PropertyListHelper::is_property_valid(const String &p_property, int *r_inde return property_list.has(components[1]); } -void PropertyListHelper::get_property_list(List *p_list, int p_count) const { - for (int i = 0; i < p_count; i++) { +void PropertyListHelper::get_property_list(List *p_list) const { + const int property_count = _call_array_length_getter(); + for (int i = 0; i < property_count; i++) { for (const KeyValue &E : property_list) { const Property &property = E.value; @@ -177,7 +178,9 @@ bool PropertyListHelper::property_get_revert(const String &p_property, Variant & PropertyListHelper::~PropertyListHelper() { // No object = it's the main helper. Do a cleanup. - if (!object) { + if (!object && is_initialized()) { + memdelete(array_length_getter); + for (const KeyValue &E : property_list) { if (E.value.setter) { memdelete(E.value.setter); diff --git a/scene/property_list_helper.h b/scene/property_list_helper.h index e19e7cd22e13..6bc65f6e3eee 100644 --- a/scene/property_list_helper.h +++ b/scene/property_list_helper.h @@ -77,7 +77,7 @@ class PropertyListHelper { void setup_for_instance(const PropertyListHelper &p_base, Object *p_object); bool is_property_valid(const String &p_property, int *r_index = nullptr) const; - void get_property_list(List *p_list, int p_count) const; + void get_property_list(List *p_list) const; bool property_get_value(const String &p_property, Variant &r_ret) const; bool property_set_value(const String &p_property, const Variant &p_value) const; bool property_can_revert(const String &p_property) const; diff --git a/servers/audio/audio_stream.h b/servers/audio/audio_stream.h index 01a4a09942f0..aa1ad4cc3ad3 100644 --- a/servers/audio/audio_stream.h +++ b/servers/audio/audio_stream.h @@ -260,7 +260,7 @@ class AudioStreamRandomizer : public AudioStream { bool _set(const StringName &p_name, const Variant &p_value) { return property_helper.property_set_value(p_name, p_value); } bool _get(const StringName &p_name, Variant &r_ret) const { return property_helper.property_get_value(p_name, r_ret); } - void _get_property_list(List *p_list) const { property_helper.get_property_list(p_list, audio_stream_pool.size()); } + void _get_property_list(List *p_list) const { property_helper.get_property_list(p_list); } bool _property_can_revert(const StringName &p_name) const { return property_helper.property_can_revert(p_name); } bool _property_get_revert(const StringName &p_name, Variant &r_property) const { return property_helper.property_get_revert(p_name, r_property); }