1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

disable all widgets before live-reloading

This commit is contained in:
Hossein Mehrabi 2018-06-08 05:31:59 +04:30
parent 9b7f31877d
commit e00a0a81a0

8
wtf.go
View File

@ -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 {