Cleanup pager processes after closing a msgviewer
A pager is spawned every time an email is viewed but not killed off when quitting the msgviewer, thus leading to process leakage. This patch fixes this by adding a Close method to the msgview widget, which is called in the close command. Signed-off-by: Kevin Kuehler <keur@xcf.berkeley.edu>
This commit is contained in:
parent
550ef0bc1f
commit
be4ea0d96b
2 changed files with 18 additions and 0 deletions
|
@ -25,6 +25,7 @@ func (Close) Execute(aerc *widgets.Aerc, args []string) error {
|
||||||
return errors.New("Usage: close")
|
return errors.New("Usage: close")
|
||||||
}
|
}
|
||||||
mv, _ := aerc.SelectedTab().(*widgets.MessageViewer)
|
mv, _ := aerc.SelectedTab().(*widgets.MessageViewer)
|
||||||
|
mv.Close()
|
||||||
aerc.RemoveTab(mv)
|
aerc.RemoveTab(mv)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,6 +284,10 @@ func (mv *MessageViewer) NextPart() {
|
||||||
mv.Invalidate()
|
mv.Invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (mv *MessageViewer) Close() {
|
||||||
|
mv.switcher.Cleanup()
|
||||||
|
}
|
||||||
|
|
||||||
func (ps *PartSwitcher) Invalidate() {
|
func (ps *PartSwitcher) Invalidate() {
|
||||||
ps.DoInvalidate(ps)
|
ps.DoInvalidate(ps)
|
||||||
}
|
}
|
||||||
|
@ -381,6 +385,12 @@ func (ps *PartSwitcher) MouseEvent(localX int, localY int, event tcell.Event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ps *PartSwitcher) Cleanup() {
|
||||||
|
for _, partViewer := range ps.parts {
|
||||||
|
partViewer.Cleanup()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (mv *MessageViewer) Event(event tcell.Event) bool {
|
func (mv *MessageViewer) Event(event tcell.Event) bool {
|
||||||
return mv.switcher.Event(event)
|
return mv.switcher.Event(event)
|
||||||
}
|
}
|
||||||
|
@ -593,6 +603,13 @@ func (pv *PartViewer) Draw(ctx *ui.Context) {
|
||||||
pv.term.Draw(ctx)
|
pv.term.Draw(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pv *PartViewer) Cleanup() {
|
||||||
|
if pv.pager != nil && pv.pager.Process != nil {
|
||||||
|
pv.pager.Process.Kill()
|
||||||
|
pv.pager = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type HeaderView struct {
|
type HeaderView struct {
|
||||||
ui.Invalidatable
|
ui.Invalidatable
|
||||||
Name string
|
Name string
|
||||||
|
|
Loading…
Reference in a new issue