summaryrefslogtreecommitdiff
path: root/gui/internal/ui/forms.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-17 11:27:00 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-17 11:27:00 +0200
commit0e56395aaa46359974a5eb21acaab32b2ea02a0f (patch)
treea245b641d3ff6deeabe411fa052d6b22b635726f /gui/internal/ui/forms.go
parent48d1781fed3f9ea5cfd2b270bd92fd2826605636 (diff)
downloadkrino-0e56395aaa46359974a5eb21acaab32b2ea02a0f.tar.gz
krino-0e56395aaa46359974a5eb21acaab32b2ea02a0f.zip
gui: an exclude is not a rule - the form no longer assumes onev0.0.11
Selecting the exclude row in Forms panicked: newFormEditor read the form's rule for its when, name, action and stop, and an exclude has only the when. The editor now takes the conditions from whichever of the two the form holds and leaves out the fields an exclude has not got. Checklist item 49 covers it. Also the 0.0.11 changelog and README, and header floors wide enough that the age heading is not clipped.
Diffstat (limited to 'gui/internal/ui/forms.go')
-rw-r--r--gui/internal/ui/forms.go26
1 files changed, 18 insertions, 8 deletions
diff --git a/gui/internal/ui/forms.go b/gui/internal/ui/forms.go
index 18a8b13..fd97546 100644
--- a/gui/internal/ui/forms.go
+++ b/gui/internal/ui/forms.go
@@ -386,7 +386,7 @@ func (r *settingRow) set(args string) {
// formLabel is one line of the list: what the form is, and what it does.
func formLabel(f model.Form) string {
- if f.Kind == model.ExcludeForm {
+ if f.Kind == model.ExcludeForm || f.Rule == nil {
return "exclude: " + f.Label
}
var what []string
@@ -677,7 +677,7 @@ func newFormEditor(form model.Form, changed func()) *formEditor {
fe.root.SetMarginTop(6)
fe.root.SetMarginBottom(6)
- if form.Kind == model.RuleForm {
+ if form.Kind == model.RuleForm && form.Rule != nil {
fe.name = gtk.NewEntry()
fe.name.SetText(form.Rule.Name)
fe.name.SetHExpand(true)
@@ -692,18 +692,25 @@ func newFormEditor(form model.Form, changed func()) *formEditor {
fe.conditions = append(fe.conditions, &model.Cond{Kind: kind})
})))
- when := form.Rule.When
- if form.Kind == model.ExcludeForm {
- when = form.Exclude.When
- } else if !form.Rule.HasWhen {
- when = nil
+ // An exclude has no rule behind it and a rule may have no (when ...) at
+ // all, so neither pointer is followed without asking first: reading
+ // form.Rule for an exclude crashed the window (found by the release
+ // checklist, 2026-09-17).
+ var when []*sexp.Node
+ switch {
+ case form.Kind == model.ExcludeForm:
+ if form.Exclude != nil {
+ when = form.Exclude.When
+ }
+ case form.Rule != nil && form.Rule.HasWhen:
+ when = form.Rule.When
}
for _, c := range when {
fe.conditions = append(fe.conditions, model.ParseCond(c))
}
fe.drawConds()
- if form.Kind == model.RuleForm {
+ if form.Kind == model.RuleForm && form.Rule != nil {
fe.acts = gtk.NewBox(gtk.OrientationVertical, 4)
fe.root.Append(heading("Actions - in order"))
fe.root.Append(fe.acts)
@@ -756,6 +763,9 @@ func (fe *formEditor) text() (string, error) {
}
return config.PrintExclude(&config.Exclude{When: when}), nil
}
+ if fe.name == nil || fe.stop == nil {
+ return "", fmt.Errorf("this form has no rule behind it")
+ }
rule := &config.Rule{
Name: fe.name.Text(),
HasWhen: len(when) > 0,