diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-10-30 17:44:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-30 17:44:23 +0100 |
commit | 60df8db401827b0ef5c767e83230766d672d20a8 (patch) | |
tree | ca8ef1bb831800d3780a189ab2adec08b0e49fee | |
parent | fd89924ea55209ff4b1353d2b91bd019cbbbcb11 (diff) | |
parent | b3f5d119aa655e24f4c998c675651e2e5b9a5f0a (diff) |
Merge pull request #12511 from sanikoyes/pr-fix-tabs-crash
Fix crash when click an empty tabs container
-rw-r--r-- | scene/gui/tab_container.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index cfe924ecd4..581034ddee 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -90,6 +90,10 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { return; } + // Do not activate tabs when tabs is empty + if (get_tab_count() == 0) + return; + Vector<Control *> tabs = _get_tabs(); // Handle navigation buttons. @@ -298,6 +302,8 @@ void TabContainer::_notification(int p_what) { } int TabContainer::_get_tab_width(int p_index) const { + + ERR_FAIL_INDEX_V(p_index, get_tab_count(), 0); Control *control = Object::cast_to<Control>(_get_tabs()[p_index]); if (!control || control->is_set_as_toplevel()) return 0; @@ -669,6 +675,7 @@ void TabContainer::_bind_methods() { TabContainer::TabContainer() { first_tab_cache = 0; + last_tab_cache = 0; buttons_visible_cache = false; tabs_ofs_cache = 0; current = 0; |