Skip to content

Commit

Permalink
Merge pull request #5465 from andydotxyz/fix/fynedologline
Browse files Browse the repository at this point in the history
Improve fyne.Do error reporting
  • Loading branch information
andydotxyz authored Jan 28, 2025
2 parents 7bfcab6 + 06c6be3 commit 4717318
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
19 changes: 13 additions & 6 deletions internal/async/goroutine.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,21 @@ func EnsureMain(fn func()) {
}

func logStackTop(skip int) {
pc := make([]uintptr, 2)
count := runtime.Callers(2+skip, pc)
pc := make([]uintptr, 16)
_ = runtime.Callers(skip, pc)
frames := runtime.CallersFrames(pc)
frame, more := frames.Next()
if more && count > 1 {
nextFrame, _ := frames.Next() // skip an occasional driver call to itself
if !strings.Contains(nextFrame.File, "runtime") { // don't descend into Go
frame = nextFrame

var nextFrame runtime.Frame
for more {
nextFrame, more = frames.Next()
if nextFrame.File == "" || strings.Contains(nextFrame.File, "runtime") { // don't descend into Go
break
}

frame = nextFrame
if !strings.Contains(nextFrame.File, "/fyne/") { // skip library lines
break
}
}
log.Printf(" From: %s:%d", frame.File, frame.Line)
Expand Down
4 changes: 2 additions & 2 deletions internal/driver/common/canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ func (c *Canvas) Painter() gl.Painter {

// Refresh refreshes a canvas object.
func (c *Canvas) Refresh(obj fyne.CanvasObject) {
c.refreshQueue.In(obj)
c.SetDirty()
c.refreshQueue.In(obj)
async.EnsureMain(c.SetDirty)
}

// RemoveShortcut removes a shortcut from the canvas.
Expand Down
15 changes: 6 additions & 9 deletions widget/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package widget // import "fyne.io/fyne/v2/widget"
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/internal/async"
"fyne.io/fyne/v2/internal/cache"
internalWidget "fyne.io/fyne/v2/internal/widget"
"fyne.io/fyne/v2/theme"
Expand Down Expand Up @@ -112,16 +111,14 @@ func (w *BaseWidget) Hide() {

// Refresh causes this widget to be redrawn in its current state
func (w *BaseWidget) Refresh() {
async.EnsureMain(func() {
impl := w.super()
if impl == nil {
return
}
impl := w.super()
if impl == nil {
return
}

w.themeCache = nil
w.themeCache = nil

cache.Renderer(impl).Refresh()
})
cache.Renderer(impl).Refresh()
}

// Theme returns a cached Theme instance for this widget (or its extending widget).
Expand Down

0 comments on commit 4717318

Please sign in to comment.