Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TabBar current tab not set correctly from previous version #97253

Closed
kitbdev opened this issue Sep 20, 2024 · 0 comments · Fixed by #97255
Closed

TabBar current tab not set correctly from previous version #97253

kitbdev opened this issue Sep 20, 2024 · 0 comments · Fixed by #97255

Comments

@kitbdev
Copy link
Contributor

kitbdev commented Sep 20, 2024

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants