diff --git a/cmd/termshark/termshark.go b/cmd/termshark/termshark.go index f5c4ee0..ce80f49 100644 --- a/cmd/termshark/termshark.go +++ b/cmd/termshark/termshark.go @@ -816,6 +816,9 @@ func cmain() int { } } + // the app variable is created here so I can bind it in the defer below + var app *gowid.App + // Do this before ui.Build. If ui.Build fails (e.g. bad TERM), then the filter will be left // running, so we need the defer to be in effect here and not after the processing of ui.Build's // error @@ -823,9 +826,17 @@ func cmain() int { if ui.FilterWidget != nil { ui.FilterWidget.Close() } + if ui.SearchWidget != nil { + ui.SearchWidget.Close(app) + } + if ui.CurrentWormholeWidget != nil { + ui.CurrentWormholeWidget.Close() + } + if ui.CurrentColsWidget != nil { + ui.CurrentColsWidget.Close() + } }() - var app *gowid.App if app, err = ui.Build(); err != nil { fmt.Fprintf(os.Stderr, "Error: %v\n", err) // Tcell returns ExitError now because if its internal terminfo DB does not have @@ -1235,15 +1246,6 @@ Loop: // will happen next time round because the quitRequested flag is checked. stopLoaders() } - if ui.CurrentWormholeWidget != nil { - ui.CurrentWormholeWidget.Close() - } - if ui.CurrentColsWidget != nil { - ui.CurrentColsWidget.Close() - } - if ui.SearchWidget != nil { - ui.SearchWidget.Close(app) - } case sig := <-sigChan: if system.IsSigTSTP(sig) {