From 5b751b6d6df3445fc66d87256bca1f089825f17a Mon Sep 17 00:00:00 2001 From: Ray Ganardi Date: Thu, 16 Apr 2020 19:29:36 +0200 Subject: 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. --- lib/ui/tab.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/ui') diff --git a/lib/ui/tab.go b/lib/ui/tab.go index 7d1ce63d..4b99e4b7 100644 --- a/lib/ui/tab.go +++ b/lib/ui/tab.go @@ -1,6 +1,8 @@ package ui import ( + "io" + "github.com/gdamore/tcell" "github.com/mattn/go-runewidth" @@ -107,6 +109,9 @@ func (tabs *Tabs) Replace(contentSrc Drawable, contentTarget Drawable, name stri if tab.Content == contentSrc { tabs.Tabs[i] = replaceTab tabs.Select(i) + if c, ok := contentSrc.(io.Closer); ok { + c.Close() + } break } } -- cgit