Skip to content

Commit

Permalink
Bug fix - close the filter goroutines when the columns dialog closes
Browse files Browse the repository at this point in the history
The columns config dialog shows a display filter validation widget for
each custom column displayed. This launches two goroutines per
filter. These should be cleaned up when the dialog closes, so as not to
leak resources. But if the dialog is closed via the escape key, for
example, the Close button logic doesn't run. The solution is to set a
callback via OnOpenClose() and shut down the filter goroutines there.
  • Loading branch information
gcla committed Feb 26, 2021
1 parent e992f0e commit 3125512
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions ui/psmlcols.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,31 +317,31 @@ func openEditColumns(app gowid.IApp) {
}),
}

cancelButton := dialog.Button{
Msg: "Cancel",
Action: gowid.WidgetChangedFunction(func(app gowid.IApp, widget gowid.IWidget) {
err := pcols.Close()
if err != nil {
log.Warnf("Unexpected result closing PSML columns dialog: %v", err)
}

editColsDialog.Close(app)
}),
}

editColsDialog = dialog.New(
framed.NewSpace(
mainw,
),
dialog.Options{
Buttons: []dialog.Button{okButton, cancelButton},
Buttons: []dialog.Button{okButton, dialog.Cancel},
NoShadow: true,
BackgroundStyle: gowid.MakePaletteRef("dialog"),
BorderStyle: gowid.MakePaletteRef("dialog"),
ButtonStyle: gowid.MakePaletteRef("dialog-button"),
},
)

dialogOpen := false
editColsDialog.OnOpenClose(gowid.MakeWidgetCallback("cb", func(app gowid.IApp, widget gowid.IWidget) {
dialogOpen = !dialogOpen
if !dialogOpen {
err := pcols.Close()
if err != nil {
log.Warnf("Unexpected result closing PSML columns dialog: %v", err)
}

}
}))

editColsDialog.Open(appView, ratio(0.7), app)
}

Expand Down

0 comments on commit 3125512

Please sign in to comment.