Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically use property count in PropertyListHelper #92283

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion editor/gui/editor_file_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<PropertyInfo> *p_list) const { property_helper.get_property_list(p_list, options.size()); }
void _get_property_list(List<PropertyInfo> *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();
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/tile_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ bool TileMap::_get(const StringName &p_name, Variant &r_ret) const {

void TileMap::_get_property_list(List<PropertyInfo> *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 {
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/file_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<PropertyInfo> *p_list) const { property_helper.get_property_list(p_list, options.size()); }
void _get_property_list(List<PropertyInfo> *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();
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/item_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<PropertyInfo> *p_list) const { property_helper.get_property_list(p_list, items.size()); }
void _get_property_list(List<PropertyInfo> *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();
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/menu_button.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<PropertyInfo> *p_list) const { property_helper.get_property_list(p_list, popup->get_item_count()); }
void _get_property_list(List<PropertyInfo> *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();
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/option_button.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<PropertyInfo> *p_list) const { property_helper.get_property_list(p_list, popup->get_item_count()); }
void _get_property_list(List<PropertyInfo> *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;
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/popup_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<PropertyInfo> *p_list) const { property_helper.get_property_list(p_list, items.size()); }
void _get_property_list(List<PropertyInfo> *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();
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/tab_bar.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<PropertyInfo> *p_list) const { property_helper.get_property_list(p_list, tabs.size()); }
void _get_property_list(List<PropertyInfo> *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);
Expand Down
9 changes: 6 additions & 3 deletions scene/property_list_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<PropertyInfo> *p_list, int p_count) const {
for (int i = 0; i < p_count; i++) {
void PropertyListHelper::get_property_list(List<PropertyInfo> *p_list) const {
const int property_count = _call_array_length_getter();
for (int i = 0; i < property_count; i++) {
for (const KeyValue<String, Property> &E : property_list) {
const Property &property = E.value;

Expand Down Expand Up @@ -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<String, Property> &E : property_list) {
if (E.value.setter) {
memdelete(E.value.setter);
Expand Down
2 changes: 1 addition & 1 deletion scene/property_list_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<PropertyInfo> *p_list, int p_count) const;
void get_property_list(List<PropertyInfo> *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;
Expand Down
2 changes: 1 addition & 1 deletion servers/audio/audio_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<PropertyInfo> *p_list) const { property_helper.get_property_list(p_list, audio_stream_pool.size()); }
void _get_property_list(List<PropertyInfo> *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); }

Expand Down
Loading