diff --git a/cmd/sointu-vsti/main.go b/cmd/sointu-vsti/main.go index bd9ed91..fa24832 100644 --- a/cmd/sointu-vsti/main.go +++ b/cmd/sointu-vsti/main.go @@ -133,17 +133,17 @@ func init() { } }, CloseFunc: func() { - t.Exec() <- func() { t.ForceQuit().Do() } + broker.ToModel <- tracker.MsgToModel{Data: func() { t.ForceQuit().Do() }} t.WaitQuitted() detector.Close() }, GetChunkFunc: func(isPreset bool) []byte { retChn := make(chan []byte) - t.Exec() <- func() { retChn <- t.MarshalRecovery() } + broker.ToModel <- tracker.MsgToModel{Data: func() { retChn <- t.MarshalRecovery() }} return <-retChn }, SetChunkFunc: func(data []byte, isPreset bool) { - t.Exec() <- func() { t.UnmarshalRecovery(data) } + broker.ToModel <- tracker.MsgToModel{Data: func() { t.UnmarshalRecovery(data) }} }, } diff --git a/tracker/gioui/tracker.go b/tracker/gioui/tracker.go index b310114..f104924 100644 --- a/tracker/gioui/tracker.go +++ b/tracker/gioui/tracker.go @@ -89,7 +89,6 @@ func NewTracker(model *tracker.Model) *Tracker { Model: model, filePathString: model.FilePath().String(), - execChan: make(chan func(), 1024), } t.Theme.Shaper = text.NewShaper(text.WithCollection(fontCollection)) t.PopupAlert = NewPopupAlert(model.Alerts(), t.Theme.Shaper) @@ -155,8 +154,6 @@ func (t *Tracker) Main() { } case <-recoveryTicker.C: t.SaveRecovery() - case f := <-t.execChan: - f() } if t.Quitted() { break @@ -181,10 +178,6 @@ func eventLoop(w *app.Window, events chan<- event.Event, acks <-chan struct{}) { } } -func (t *Tracker) Exec() chan<- func() { - return t.execChan -} - func (t *Tracker) WaitQuitted() { t.quitWG.Wait() } @@ -261,14 +254,14 @@ func (t *Tracker) explorerChooseFile(success func(io.ReadCloser), extensions ... t.Exploring = true go func() { file, err := t.Explorer.ChooseFile(extensions...) - t.Exec() <- func() { + t.Broker().ToModel <- tracker.MsgToModel{Data: func() { t.Exploring = false if err == nil { success(file) } else { t.Cancel().Do() } - } + }} }() } @@ -276,14 +269,14 @@ func (t *Tracker) explorerCreateFile(success func(io.WriteCloser), filename stri t.Exploring = true go func() { file, err := t.Explorer.CreateFile(filename) - t.Exec() <- func() { + t.Broker().ToModel <- tracker.MsgToModel{Data: func() { t.Exploring = false if err == nil { success(file) } else { t.Cancel().Do() } - } + }} }() }