Fix Fyne threading errors in benchmark progress updates
All UI updates from the benchmark goroutine were causing threading errors because they weren't wrapped in DoFromGoroutine. Fixed: - UpdateProgress: progress bar and label updates - AddResult: adding result cards to the display - SetComplete: final status updates These methods are called from background goroutines running the benchmark tests, so all UI updates must be dispatched to the main thread using fyne.CurrentApp().Driver().DoFromGoroutine(). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
4d99f6ec78
commit
1447e1478f
|
|
@ -113,12 +113,14 @@ func (v *BenchmarkProgressView) GetContainer() *fyne.Container {
|
||||||
// UpdateProgress updates the progress bar and labels
|
// UpdateProgress updates the progress bar and labels
|
||||||
func (v *BenchmarkProgressView) UpdateProgress(current, total int, encoder, preset string) {
|
func (v *BenchmarkProgressView) UpdateProgress(current, total int, encoder, preset string) {
|
||||||
pct := float64(current) / float64(total)
|
pct := float64(current) / float64(total)
|
||||||
v.progressBar.SetValue(pct)
|
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
||||||
v.statusLabel.SetText(fmt.Sprintf("Testing encoder %d of %d", current, total))
|
v.progressBar.SetValue(pct)
|
||||||
v.currentLabel.SetText(fmt.Sprintf("Testing: %s (preset: %s)", encoder, preset))
|
v.statusLabel.SetText(fmt.Sprintf("Testing encoder %d of %d", current, total))
|
||||||
v.progressBar.Refresh()
|
v.currentLabel.SetText(fmt.Sprintf("Testing: %s (preset: %s)", encoder, preset))
|
||||||
v.statusLabel.Refresh()
|
v.progressBar.Refresh()
|
||||||
v.currentLabel.Refresh()
|
v.statusLabel.Refresh()
|
||||||
|
v.currentLabel.Refresh()
|
||||||
|
}, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddResult adds a completed test result to the display
|
// AddResult adds a completed test result to the display
|
||||||
|
|
@ -162,20 +164,24 @@ func (v *BenchmarkProgressView) AddResult(result benchmark.Result) {
|
||||||
container.NewMax(card, content),
|
container.NewMax(card, content),
|
||||||
)
|
)
|
||||||
|
|
||||||
v.resultsBox.Add(item)
|
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
||||||
v.resultsBox.Refresh()
|
v.resultsBox.Add(item)
|
||||||
|
v.resultsBox.Refresh()
|
||||||
|
}, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetComplete marks the benchmark as complete
|
// SetComplete marks the benchmark as complete
|
||||||
func (v *BenchmarkProgressView) SetComplete() {
|
func (v *BenchmarkProgressView) SetComplete() {
|
||||||
v.statusLabel.SetText("Benchmark complete!")
|
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
||||||
v.progressBar.SetValue(1.0)
|
v.statusLabel.SetText("Benchmark complete!")
|
||||||
v.currentLabel.SetText("")
|
v.progressBar.SetValue(1.0)
|
||||||
v.cancelBtn.SetText("Close")
|
v.currentLabel.SetText("")
|
||||||
v.statusLabel.Refresh()
|
v.cancelBtn.SetText("Close")
|
||||||
v.progressBar.Refresh()
|
v.statusLabel.Refresh()
|
||||||
v.currentLabel.Refresh()
|
v.progressBar.Refresh()
|
||||||
v.cancelBtn.Refresh()
|
v.currentLabel.Refresh()
|
||||||
|
v.cancelBtn.Refresh()
|
||||||
|
}, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// BuildBenchmarkResultsView creates the final results/recommendation UI
|
// BuildBenchmarkResultsView creates the final results/recommendation UI
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user