Skip to content

Commit b365a63

Browse files
committed
Automatically use property count in PropertyListHelper
1 parent b7feebe commit b365a63

File tree

11 files changed

+16
-13
lines changed

11 files changed

+16
-13
lines changed

editor/gui/editor_file_dialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ class EditorFileDialog : public ConfirmationDialog {
268268
void _notification(int p_what);
269269
bool _set(const StringName &p_name, const Variant &p_value) { return property_helper.property_set_value(p_name, p_value); }
270270
bool _get(const StringName &p_name, Variant &r_ret) const { return property_helper.property_get_value(p_name, r_ret); }
271-
void _get_property_list(List<PropertyInfo> *p_list) const { property_helper.get_property_list(p_list, options.size()); }
271+
void _get_property_list(List<PropertyInfo> *p_list) const { property_helper.get_property_list(p_list); }
272272
bool _property_can_revert(const StringName &p_name) const { return property_helper.property_can_revert(p_name); }
273273
bool _property_get_revert(const StringName &p_name, Variant &r_property) const { return property_helper.property_get_revert(p_name, r_property); }
274274
static void _bind_methods();

scene/2d/tile_map.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ bool TileMap::_get(const StringName &p_name, Variant &r_ret) const {
722722

723723
void TileMap::_get_property_list(List<PropertyInfo> *p_list) const {
724724
p_list->push_back(PropertyInfo(Variant::INT, "format", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL));
725-
property_helper.get_property_list(p_list, layers.size());
725+
property_helper.get_property_list(p_list);
726726
}
727727

728728
Vector2 TileMap::map_to_local(const Vector2i &p_pos) const {

scene/gui/file_dialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class FileDialog : public ConfirmationDialog {
194194
void _notification(int p_what);
195195
bool _set(const StringName &p_name, const Variant &p_value) { return property_helper.property_set_value(p_name, p_value); }
196196
bool _get(const StringName &p_name, Variant &r_ret) const { return property_helper.property_get_value(p_name, r_ret); }
197-
void _get_property_list(List<PropertyInfo> *p_list) const { property_helper.get_property_list(p_list, options.size()); }
197+
void _get_property_list(List<PropertyInfo> *p_list) const { property_helper.get_property_list(p_list); }
198198
bool _property_can_revert(const StringName &p_name) const { return property_helper.property_can_revert(p_name); }
199199
bool _property_get_revert(const StringName &p_name, Variant &r_property) const { return property_helper.property_get_revert(p_name, r_property); }
200200
static void _bind_methods();

scene/gui/item_list.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class ItemList : public Control {
162162
void _notification(int p_what);
163163
bool _set(const StringName &p_name, const Variant &p_value);
164164
bool _get(const StringName &p_name, Variant &r_ret) const { return property_helper.property_get_value(p_name, r_ret); }
165-
void _get_property_list(List<PropertyInfo> *p_list) const { property_helper.get_property_list(p_list, items.size()); }
165+
void _get_property_list(List<PropertyInfo> *p_list) const { property_helper.get_property_list(p_list); }
166166
bool _property_can_revert(const StringName &p_name) const { return property_helper.property_can_revert(p_name); }
167167
bool _property_get_revert(const StringName &p_name, Variant &r_property) const { return property_helper.property_get_revert(p_name, r_property); }
168168
static void _bind_methods();

scene/gui/menu_button.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class MenuButton : public Button {
5252
void _notification(int p_what);
5353
bool _set(const StringName &p_name, const Variant &p_value);
5454
bool _get(const StringName &p_name, Variant &r_ret) const;
55-
void _get_property_list(List<PropertyInfo> *p_list) const { property_helper.get_property_list(p_list, popup->get_item_count()); }
55+
void _get_property_list(List<PropertyInfo> *p_list) const { property_helper.get_property_list(p_list); }
5656
bool _property_can_revert(const StringName &p_name) const { return property_helper.property_can_revert(p_name); }
5757
bool _property_get_revert(const StringName &p_name, Variant &r_property) const { return property_helper.property_get_revert(p_name, r_property); }
5858
static void _bind_methods();

scene/gui/option_button.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class OptionButton : public Button {
8484
void _notification(int p_what);
8585
bool _set(const StringName &p_name, const Variant &p_value);
8686
bool _get(const StringName &p_name, Variant &r_ret) const { return property_helper.property_get_value(p_name, r_ret); }
87-
void _get_property_list(List<PropertyInfo> *p_list) const { property_helper.get_property_list(p_list, popup->get_item_count()); }
87+
void _get_property_list(List<PropertyInfo> *p_list) const { property_helper.get_property_list(p_list); }
8888
bool _property_can_revert(const StringName &p_name) const { return property_helper.property_can_revert(p_name); }
8989
bool _property_get_revert(const StringName &p_name, Variant &r_property) const { return property_helper.property_get_revert(p_name, r_property); }
9090
void _validate_property(PropertyInfo &p_property) const;

scene/gui/popup_menu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class PopupMenu : public Popup {
218218
void _notification(int p_what);
219219
bool _set(const StringName &p_name, const Variant &p_value);
220220
bool _get(const StringName &p_name, Variant &r_ret) const { return property_helper.property_get_value(p_name, r_ret); }
221-
void _get_property_list(List<PropertyInfo> *p_list) const { property_helper.get_property_list(p_list, items.size()); }
221+
void _get_property_list(List<PropertyInfo> *p_list) const { property_helper.get_property_list(p_list); }
222222
bool _property_can_revert(const StringName &p_name) const { return property_helper.property_can_revert(p_name); }
223223
bool _property_get_revert(const StringName &p_name, Variant &r_property) const { return property_helper.property_get_revert(p_name, r_property); }
224224
static void _bind_methods();

scene/gui/tab_bar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class TabBar : public Control {
175175

176176
bool _set(const StringName &p_name, const Variant &p_value) { return property_helper.property_set_value(p_name, p_value); }
177177
bool _get(const StringName &p_name, Variant &r_ret) const { return property_helper.property_get_value(p_name, r_ret); }
178-
void _get_property_list(List<PropertyInfo> *p_list) const { property_helper.get_property_list(p_list, tabs.size()); }
178+
void _get_property_list(List<PropertyInfo> *p_list) const { property_helper.get_property_list(p_list); }
179179
bool _property_can_revert(const StringName &p_name) const { return property_helper.property_can_revert(p_name); }
180180
bool _property_get_revert(const StringName &p_name, Variant &r_property) const { return property_helper.property_get_revert(p_name, r_property); }
181181
void _notification(int p_what);

scene/property_list_helper.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ bool PropertyListHelper::is_property_valid(const String &p_property, int *r_inde
122122
return property_list.has(components[1]);
123123
}
124124

125-
void PropertyListHelper::get_property_list(List<PropertyInfo> *p_list, int p_count) const {
126-
for (int i = 0; i < p_count; i++) {
125+
void PropertyListHelper::get_property_list(List<PropertyInfo> *p_list) const {
126+
const int property_count = _call_array_length_getter();
127+
for (int i = 0; i < property_count; i++) {
127128
for (const KeyValue<String, Property> &E : property_list) {
128129
const Property &property = E.value;
129130

@@ -177,7 +178,9 @@ bool PropertyListHelper::property_get_revert(const String &p_property, Variant &
177178

178179
PropertyListHelper::~PropertyListHelper() {
179180
// No object = it's the main helper. Do a cleanup.
180-
if (!object) {
181+
if (!object && is_initialized()) {
182+
memdelete(array_length_getter);
183+
181184
for (const KeyValue<String, Property> &E : property_list) {
182185
if (E.value.setter) {
183186
memdelete(E.value.setter);

scene/property_list_helper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class PropertyListHelper {
7777
void setup_for_instance(const PropertyListHelper &p_base, Object *p_object);
7878
bool is_property_valid(const String &p_property, int *r_index = nullptr) const;
7979

80-
void get_property_list(List<PropertyInfo> *p_list, int p_count) const;
80+
void get_property_list(List<PropertyInfo> *p_list) const;
8181
bool property_get_value(const String &p_property, Variant &r_ret) const;
8282
bool property_set_value(const String &p_property, const Variant &p_value) const;
8383
bool property_can_revert(const String &p_property) const;

0 commit comments

Comments
 (0)