fix: Close unused MessageView when swapping view
Closes https://todo.sr.ht/~sircmpwn/aerc2/379 The old `MessageView` was not closed when replacing the tab content, which causes a memory leak.
This commit is contained in:
parent
f35002ad0e
commit
5b751b6d6d
2 changed files with 7 additions and 1 deletions
|
@ -1,6 +1,8 @@
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
"github.com/gdamore/tcell"
|
"github.com/gdamore/tcell"
|
||||||
"github.com/mattn/go-runewidth"
|
"github.com/mattn/go-runewidth"
|
||||||
|
|
||||||
|
@ -107,6 +109,9 @@ func (tabs *Tabs) Replace(contentSrc Drawable, contentTarget Drawable, name stri
|
||||||
if tab.Content == contentSrc {
|
if tab.Content == contentSrc {
|
||||||
tabs.Tabs[i] = replaceTab
|
tabs.Tabs[i] = replaceTab
|
||||||
tabs.Select(i)
|
tabs.Select(i)
|
||||||
|
if c, ok := contentSrc.(io.Closer); ok {
|
||||||
|
c.Close()
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -317,8 +317,9 @@ func (mv *MessageViewer) NextPart() {
|
||||||
mv.Invalidate()
|
mv.Invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mv *MessageViewer) Close() {
|
func (mv *MessageViewer) Close() error {
|
||||||
mv.switcher.Cleanup()
|
mv.switcher.Cleanup()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ps *PartSwitcher) Invalidate() {
|
func (ps *PartSwitcher) Invalidate() {
|
||||||
|
|
Loading…
Reference in a new issue