summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-02-14 15:21:18 +0100
committerGitHub <noreply@github.com>2022-02-14 15:21:18 +0100
commitaf98de882337cfff38780642a4892edf8e89a888 (patch)
treee41b1a3d8cb4dc88d409f267878a5b05e9458fc5 /scene/gui
parent6e73aa0497b9cfc1c28863e655991106e677e69c (diff)
parent2b4d417e994290ba0cf762eff8b78e6377588aaa (diff)
Merge pull request #58089 from YeldhamDev/crashy_tabs
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/tab_bar.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/scene/gui/tab_bar.cpp b/scene/gui/tab_bar.cpp
index b1baacd887..607031bee6 100644
--- a/scene/gui/tab_bar.cpp
+++ b/scene/gui/tab_bar.cpp
@@ -524,13 +524,14 @@ 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);
- }
- _update_cache();
- _ensure_no_over_offset();
- if (scroll_to_selected) {
- ensure_tab_visible(current);
+ _update_cache();
+ _ensure_no_over_offset();
+ if (scroll_to_selected) {
+ ensure_tab_visible(current);
+ }
}
+
update();
update_minimum_size();
notify_property_list_changed();
@@ -961,7 +962,6 @@ void TabBar::clear_tabs() {
current = 0;
previous = 0;
- _update_cache();
update();
update_minimum_size();
notify_property_list_changed();
@@ -975,18 +975,21 @@ void TabBar::remove_tab(int p_idx) {
}
if (current < 0) {
+ offset = 0;
+ max_drawn_tab = 0;
current = 0;
previous = 0;
- }
- if (current >= tabs.size()) {
- current = tabs.size() - 1;
- }
+ } else {
+ offset = MIN(offset, tabs.size() - 1);
+ max_drawn_tab = MIN(max_drawn_tab, tabs.size() - 1);
- _update_cache();
- _ensure_no_over_offset();
- if (scroll_to_selected && !tabs.is_empty()) {
- ensure_tab_visible(current);
+ _update_cache();
+ _ensure_no_over_offset();
+ if (scroll_to_selected && !tabs.is_empty()) {
+ ensure_tab_visible(current);
+ }
}
+
update();
update_minimum_size();
notify_property_list_changed();