Skip to content

Commit

Permalink
Merge pull request #88494 from AThousandShips/tab_fix
Browse files Browse the repository at this point in the history
Fix error spam when adding tabs to `TabBar` without deselect
  • Loading branch information
akien-mga committed Feb 22, 2024
2 parents c3de771 + a56c03d commit 0a3f162
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions scene/gui/tab_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 0a3f162

Please sign in to comment.