Skip to content

Commit

Permalink
Merge pull request #88731 from ajreckof/Removing-element-in-array-wil…
Browse files Browse the repository at this point in the history
…l-not-change-page-when-emptying-page-

Fix removing element in array inspector not changing page when emptying page.
  • Loading branch information
akien-mga committed Feb 23, 2024
2 parents 4ec8976 + 4f2074e commit 2fe8f07
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions editor/editor_properties_array_dict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void EditorPropertyArray::_property_changed(const String &p_property, Variant p_

void EditorPropertyArray::_change_type(Object *p_button, int p_slot_index) {
Button *button = Object::cast_to<Button>(p_button);
changing_type_index = slots[p_slot_index].index;
changing_type_index = p_slot_index;
Rect2 rect = button->get_screen_rect();
change_type->reset_size();
change_type->set_position(rect.get_end() - Vector2(change_type->get_contents_minimum_size().x, 0));
Expand All @@ -228,7 +228,7 @@ void EditorPropertyArray::_change_type_menu(int p_index) {
VariantInternal::initialize(&value, Variant::Type(p_index));

Variant array = object->get_array().duplicate();
array.set(changing_type_index, value);
array.set(slots[changing_type_index].index, value);

emit_changed(get_edited_property(), array, "", true);
update_property();
Expand Down Expand Up @@ -311,7 +311,9 @@ void EditorPropertyArray::update_property() {

int size = array.call("size");
int max_page = MAX(0, size - 1) / page_length;
page_index = MIN(page_index, max_page);
if (page_index > max_page) {
_page_changed(max_page);
}

edit->set_text(vformat(TTR("%s (size %s)"), array_type_name, itos(size)));

Expand Down

0 comments on commit 2fe8f07

Please sign in to comment.