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

TabContainer Panic when removing tabs and selected tab is becomes of range #1668

Closed
adrianre12 opened this issue Dec 18, 2020 · 1 comment · Fixed by #1670
Closed

TabContainer Panic when removing tabs and selected tab is becomes of range #1668

adrianre12 opened this issue Dec 18, 2020 · 1 comment · Fixed by #1670
Labels
blocker Items that would block a forthcoming release bug Something isn't working

Comments

@adrianre12
Copy link
Contributor

Describe the bug:

When removing tabs from a TabContainer this panic is thrown
fyne.io/fyne/widget.(*TabContainer).RemoveIndex(...) C:/Users/Adrian/go/pkg/mod/fyne.io/fyne@v1.4.2/widget/tabcontainer.go:125 main.main.func3() C:/Users/Adrian/go/src/Test/main.go:16 +0x18f fyne.io/fyne/widget.(*Button).Tapped(0xc0000ca160, 0xc00008c0e0) C:/Users/Adrian/go/pkg/mod/fyne.io/fyne@v1.4.2/widget/button.go:196 +0xaa fyne.io/fyne/internal/driver/glfw.(*window).mouseClicked.func5() C:/Users/Adrian/go/pkg/mod/fyne.io/fyne@v1.4.2/internal/driver/glfw/window.go:738 +0x3f fyne.io/fyne/internal/driver/glfw.(*window).runEventQueue(0xc0000a8000) C:/Users/Adrian/go/pkg/mod/fyne.io/fyne@v1.4.2/internal/driver/glfw/window.go:1156 +0x83 created by fyne.io/fyne/internal/driver/glfw.(*gLDriver).createWindow.func1 C:/Users/Adrian/go/pkg/mod/fyne.io/fyne@v1.4.2/internal/driver/glfw/window.go:1180 +0x10d

It happens when the selected tab becomes out of range for the []items i.e. TabContainer.current > len(TabContainer.Items) - 1
I.E tabs A B C, select C, then remove C results in panic
I have also noticed that if the selected tab is removed and it is not out of range then the selected tab remains at the same value. Not sure if this is desirable behaviour. I.E tabs A B C, select B, then remove B. tabs become A B, and B is still selected.

Example code:

With this example follow the above instructions
`package main

import (
"fyne.io/fyne"
"fyne.io/fyne/app"
"fyne.io/fyne/widget"
)

func main() {
myApp := app.New()
myWindow := myApp.NewWindow("TabContainer Widget")
tabs := widget.NewTabContainer()
tabs.Append(widget.NewTabItem("Tab A", widget.NewButton("Remove A", func() { tabs.RemoveIndex(0) })))
tabs.Append(widget.NewTabItem("Tab B", widget.NewButton("Remove B", func() { tabs.RemoveIndex(1) })))
tabs.Append(widget.NewTabItem("Tab C", widget.NewButton("Remove C", func() { tabs.RemoveIndex(2) })))
tabs.SetTabLocation(widget.TabLocationTop)
myWindow.SetContent(tabs)
myWindow.Resize(fyne.NewSize(600, 600))
myWindow.ShowAndRun()
}
`

Device (please complete the following information):

  • OS: Windows
  • Version: 10
  • Go version: go1.15.5 windows/amd64
  • Fyne version: 1.4.2
@andydotxyz andydotxyz added blocker Items that would block a forthcoming release bug Something isn't working labels Dec 18, 2020
adrianre12 added a commit to adrianre12/fyne that referenced this issue Dec 18, 2020
andydotxyz added a commit that referenced this issue Dec 28, 2020
…n-removing-tabs

#1668 tab container panic when removing tabs
@andydotxyz
Copy link
Member

on release/v1.4.x for testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker Items that would block a forthcoming release bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants