Skip to content

Commit

Permalink
make sure data incoming from the TRX is handled in the UI thread
Browse files Browse the repository at this point in the history
  • Loading branch information
ftl committed Apr 5, 2021
1 parent 40884b1 commit cef3360
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ui/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ func (a *application) shutdown() {
}

func (a *application) runAsync(f func()) {
runAsync(f)
}

func runAsync(f func()) {
glib.IdleAdd(func() bool {
f()
return false
Expand Down
16 changes: 12 additions & 4 deletions ui/entryView.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,19 @@ func (v *entryView) setTextWithoutChangeEvent(f func(string), value string) {
}

func (v *entryView) SetUTC(text string) {
v.utc.SetText(text)
runAsync(func() {
v.utc.SetText(text)
})
}

func (v *entryView) SetMyCall(text string) {
v.myCall.SetText(text)
}

func (v *entryView) SetFrequency(frequency core.Frequency) {
v.frequency.SetText(fmt.Sprintf("%7.2f kHz", frequency/1000.0))
runAsync(func() {
v.frequency.SetText(fmt.Sprintf("%7.2f kHz", frequency/1000.0))
})
}

func (v *entryView) SetCallsign(text string) {
Expand All @@ -235,11 +239,15 @@ func (v *entryView) SetTheirXchange(text string) {
}

func (v *entryView) SetBand(text string) {
v.setTextWithoutChangeEvent(func(s string) { v.band.SetActiveID(s) }, text)
runAsync(func() {
v.setTextWithoutChangeEvent(func(s string) { v.band.SetActiveID(s) }, text)
})
}

func (v *entryView) SetMode(text string) {
v.setTextWithoutChangeEvent(func(s string) { v.mode.SetActiveID(s) }, text)
runAsync(func() {
v.setTextWithoutChangeEvent(func(s string) { v.mode.SetActiveID(s) }, text)
})
}

func (v *entryView) SetMyReport(text string) {
Expand Down

0 comments on commit cef3360

Please sign in to comment.