Skip to content

Commit

Permalink
egui: add nil guards to prevent crash in looperctrl
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoreilly committed Nov 7, 2024
1 parent 9c72105 commit 9706a37
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions egui/loopctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ func (gui *GUI) AddLooperCtrl(p *tree.Plan, loops *looper.Stacks, prefix ...stri
s.Grow.Set(0, 0)
})
w.OnChange(func(e events.Event) {
curMode = w.SelectedItem().Value.(enums.Enum)
sel := w.SelectedItem()
if sel == nil || sel.Value == nil {
return
}
curMode = sel.Value.(enums.Enum)
st := loops.Stacks[curMode]
if st != nil {
curStep = st.StepLevel
Expand Down Expand Up @@ -148,7 +152,10 @@ func (gui *GUI) AddLooperCtrl(p *tree.Plan, loops *looper.Stacks, prefix ...stri
w.SetCurrentValue(curStep.String())
w.OnChange(func(e events.Event) {
st := loops.Stacks[curMode]
cs := stepChoose.CurrentItem.Value.(string)
if w.CurrentItem.Value == nil {
return
}
cs := w.CurrentItem.Value.(string)
for _, l := range st.Order {
if l.String() == cs {
st.StepLevel = l
Expand Down

0 comments on commit 9706a37

Please # to comment.