msgviewer: cleanup PartSwitcher on :toggle-headers

Cleanup existing PartSwitcher before recreating a new one when command
:toggle-headers is executed, ensuring existing part pagers are cleaned
up.  This fixes a leak in pager processes when :toggle-headers is
executed repeatedly without closing the message.

Signed-off-by: Jose Lombera <jose@lombera.dev>
Acked-by: Koni Marti <koni.marti@gmail.com>
This commit is contained in:
Jose Lombera 2022-07-22 18:17:46 -05:00 committed by Robin Jarry
parent 5dec1f09b1
commit c49a065496
1 changed files with 1 additions and 0 deletions

View File

@ -308,6 +308,7 @@ func (mv *MessageViewer) MarkedMessages() ([]uint32, error) {
func (mv *MessageViewer) ToggleHeaders() { func (mv *MessageViewer) ToggleHeaders() {
switcher := mv.switcher switcher := mv.switcher
switcher.Cleanup()
mv.conf.Viewer.ShowHeaders = !mv.conf.Viewer.ShowHeaders mv.conf.Viewer.ShowHeaders = !mv.conf.Viewer.ShowHeaders
err := createSwitcher(mv.acct, switcher, mv.conf, mv.msg) err := createSwitcher(mv.acct, switcher, mv.conf, mv.msg)
if err != nil { if err != nil {