summary refs log tree commit diff stats
path: root/lib/ui
diff options
context:
space:
mode:
authorRay Ganardi <ray@ganardi.xyz>2020-04-16 19:29:36 +0200
committerDrew DeVault <sir@cmpwn.com>2020-04-20 10:48:40 -0400
commit5b751b6d6df3445fc66d87256bca1f089825f17a (patch)
tree6f138ff41274b60e65860f7acb7991bdb6f4a7bc /lib/ui
parentf35002ad0e1fae9c62e598b229e32b16a8eb702c (diff)
downloadaerc-5b751b6d6df3445fc66d87256bca1f089825f17a.tar.gz
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.
Diffstat (limited to 'lib/ui')
-rw-r--r--lib/ui/tab.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/ui/tab.go b/lib/ui/tab.go
index 7d1ce63..4b99e4b 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
 		}
 	}