Skip to content

Commit

Permalink
Fix deadlocking on Linux clipboard test (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Dec 17, 2024
1 parent dceb723 commit f0bf159
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions internal/driver/glfw/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,13 @@ func (w *window) Close() {

// trigger callbacks - early so window still exists
if w.onClosed != nil {
w.QueueEvent(w.onClosed)
w.onClosed()
}

// set w.closing flag inside draw thread to ensure we can free textures
runOnMainWithContext(w, func() {
w.closing = true
w.viewport.SetShouldClose(true)

cache.RangeTexturesFor(w.canvas, w.canvas.Painter().Free)
})
w.closing = true
w.viewport.SetShouldClose(true)

cache.RangeTexturesFor(w.canvas, w.canvas.Painter().Free)
w.canvas.WalkTrees(nil, func(node *common.RenderCacheNode, _ fyne.Position) {
if wid, ok := node.Obj().(fyne.Widget); ok {
cache.DestroyRenderer(wid)
Expand Down
2 changes: 1 addition & 1 deletion internal/driver/glfw/window_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1668,7 +1668,7 @@ func TestWindow_CloseInterception(t *testing.T) {
w.SetCloseIntercept(func() { onIntercepted = true })
w.SetOnClosed(func() { onClosed = true })
w.Close()
w.WaitForEvents()

assert.False(t, onIntercepted, "the interceptor should not have been called")
assert.True(t, onClosed, "the on closed handler should have been called")
assert.True(t, w.viewport.ShouldClose()) // For #2694
Expand Down

0 comments on commit f0bf159

Please sign in to comment.