Description
Tested versions
v4.3.stable.official [77dcf97], master
System information
Windows 10.0.22631 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2070 (NVIDIA; 31.0.15.5186) - Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz (12 Threads)
Issue description
When opening a scene from a previous version with a TabBar that does not have the current_tab property set (default), the default tab for a TabBar will not be set to the first tab.
This is because TabBar::set_tab_count
will set the current tab to -1 if the current tab was not set before tabs were added. This can be seen by calling the set_tab_count()
manually as well.
Also related:
In TabContainer and TabBar (if there are no tabs set in the inspector), setting the current tab to an invalid value does not show error or do anything. Calling TabBar::set_tab_count
afterwards will set current tab to that invalid value. It also will not emit a tab_changed signal or update the previous tab.
- The default changed in Allow no tabs to be selected in TabBar and TabContainer #87194
- The current tab was made sure to be correct in Fix error spam when adding tabs to
TabBar
without deselect #88494 - But it gets overridden in Tweak property order in the inspector for TabBar #88477
This is because it assumes thatTabBar::set_tab_count
andTabBar::set_current_tab
will be called, but they may not be.
So it looks like a regression from #88477
I am working on a comprehensive fix for this.
Steps to reproduce
- Make a TabBar in a previous version, like 4.2 with at least one tab. The current_tab property should be left as the default.
- Change version to 4.3 or later.
- The TabBar will not select the first tab by default anymore.
For setting an invalid current tab:
- Add a script to a TabBar, make sure no tabs are added in to it in the inspector.
- Set
current_tab = 100
or some invalid value. No error will be shown. - Call
set_tab_count(1)
. - The current tab will be the previous invalid value.
Minimal reproduction project (MRP)
tab_bar_current_tab_init_issue.zip
Three issues are shown in the MRP:
- A TabBar with valid tabs, but current tab is still -1.
- A TabContainer trying to set the current tab to an invalid value, it doesn't work but no error is shown.
- And a TabBar that does sets the current tab to an invalid value by using
set_tab_count
.