mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Fix error spam when adding tabs to TabBar without deselect
`current` was allowed to be `-1` when deselection was disabled, causing errors in other methods when updating the size.
This commit is contained in:
@@ -627,6 +627,10 @@ void TabBar::set_tab_count(int p_count) {
|
||||
offset = MIN(offset, p_count - 1);
|
||||
max_drawn_tab = MIN(max_drawn_tab, p_count - 1);
|
||||
current = MIN(current, p_count - 1);
|
||||
// Fix range if unable to deselect.
|
||||
if (current == -1 && !_can_deselect()) {
|
||||
current = 0;
|
||||
}
|
||||
|
||||
_update_cache();
|
||||
_ensure_no_over_offset();
|
||||
@@ -1557,10 +1561,7 @@ bool TabBar::_can_deselect() const {
|
||||
}
|
||||
|
||||
void TabBar::ensure_tab_visible(int p_idx) {
|
||||
if (!is_inside_tree() || !buttons_visible) {
|
||||
return;
|
||||
}
|
||||
if (p_idx == -1 && _can_deselect()) {
|
||||
if (p_idx == -1 || !is_inside_tree() || !buttons_visible) {
|
||||
return;
|
||||
}
|
||||
ERR_FAIL_INDEX(p_idx, tabs.size());
|
||||
|
||||
Reference in New Issue
Block a user