|
func set_element_count(element_count: int, force_update: bool = false) -> void: |
|
element_count = maxi(element_count, 0) |
|
if _element_count == element_count and not force_update: |
|
return |
|
|
|
_hseparator.set_visible(element_count > PAGE_SIZE) |
|
_footer.set_visible(_hseparator.is_visible()) |
|
|
|
_page_count = floori(float(element_count - 1) / PAGE_SIZE) |
|
_page_label.set_text("/ %d" % _page_count) |
|
|
|
_current_page = clampi(_current_page, 0, _page_count) |
|
_page_edit.set_text(str(_current_page)) |
|
|
|
_element_count = element_count |
|
update_elements() |
If the element count is 0, it will calculate a page_count of -1 and set a current_page of -1.
Eventually, it will construct a page starting from array index _current_page * PAGE_SIZE, which is negative and results in a runtime exception
object-inspector/scripts/inspector_property_paginator.gd
Lines 91 to 106 in fdce48b
If the element count is 0, it will calculate a
page_countof -1 and set acurrent_pageof -1.Eventually, it will construct a page starting from array index
_current_page * PAGE_SIZE, which is negative and results in a runtime exception