Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve fyne.Do error reporting #5465

Merged
merged 3 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading