fix panic on closing a tab
This change fixes a panic caused by the selected tab being out of sync when selecting a new one in widgets.(*Aerc).SelectedTab(). This happens if the tab is already removed from the list of tabs, but the selection not yet being updated. This was achieved by moving the tabs behind updating the selection. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
This commit is contained in:
parent
aae46c7afd
commit
d7feb56cbe
1 changed files with 6 additions and 2 deletions
|
@ -74,10 +74,13 @@ func (tabs *Tabs) invalidateChild(d Drawable) {
|
||||||
|
|
||||||
func (tabs *Tabs) Remove(content Drawable) {
|
func (tabs *Tabs) Remove(content Drawable) {
|
||||||
indexToRemove := -1
|
indexToRemove := -1
|
||||||
|
removeTab := func() {}
|
||||||
for i, tab := range tabs.Tabs {
|
for i, tab := range tabs.Tabs {
|
||||||
if tab.Content == content {
|
if tab.Content == content {
|
||||||
tabs.Tabs = append(tabs.Tabs[:i], tabs.Tabs[i+1:]...)
|
removeTab = func() {
|
||||||
tabs.removeHistory(i)
|
tabs.Tabs = append(tabs.Tabs[:i], tabs.Tabs[i+1:]...)
|
||||||
|
tabs.removeHistory(i)
|
||||||
|
}
|
||||||
indexToRemove = i
|
indexToRemove = i
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -99,6 +102,7 @@ func (tabs *Tabs) Remove(content Drawable) {
|
||||||
// selected tab is now one to the left of where it was
|
// selected tab is now one to the left of where it was
|
||||||
tabs.Selected--
|
tabs.Selected--
|
||||||
}
|
}
|
||||||
|
removeTab()
|
||||||
tabs.TabStrip.Invalidate()
|
tabs.TabStrip.Invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue