From e00a0a81a06ea2ccd427b2d5b9fa8b54e197ecbe Mon Sep 17 00:00:00 2001 From: Hossein Mehrabi Date: Fri, 8 Jun 2018 05:31:59 +0430 Subject: [PATCH] disable all widgets before live-reloading --- wtf.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wtf.go b/wtf.go index f0df2b06..da5e5afd 100644 --- a/wtf.go +++ b/wtf.go @@ -121,6 +121,8 @@ func watchForConfigChanges(app *tview.Application, configFlag string, grid *tvie select { case <-watch.Event: loadConfig(configFlag) + // Disable all widgets to stop scheduler goroutines and widgets from memory. + disableAllWidgets() makeWidgets(app, pages) grid = buildGrid(Widgets) pages.AddPage("grid", grid, true, true) @@ -155,6 +157,12 @@ var ( version = "dev" ) +func disableAllWidgets() { + for _, widget := range Widgets { + widget.Disable() + } +} + func addWidget(app *tview.Application, pages *tview.Pages, widgetName string) { // Always in alphabetical order switch widgetName {