diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-02-22 11:23:15 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-02-22 11:23:15 +0100 |
commit | 0a3f162f17bbe1c63f8691131bba84017ba6c557 (patch) | |
tree | 7a76188c87a57071202e625e948c7fa16f2e1906 | |
parent | c3de771292da796ce89e1668a96668a197c20a4f (diff) | |
parent | a56c03d49584c81f67b24a508fbe87916b749275 (diff) | |
download | redot-engine-0a3f162f17bbe1c63f8691131bba84017ba6c557.tar.gz |
Merge pull request #88494 from AThousandShips/tab_fix
Fix error spam when adding tabs to `TabBar` without deselect
-rw-r--r-- | scene/gui/tab_bar.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/scene/gui/tab_bar.cpp b/scene/gui/tab_bar.cpp index f87bccdfe7..d20fef8164 100644 --- a/scene/gui/tab_bar.cpp +++ b/scene/gui/tab_bar.cpp @@ -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()); |