From f0bf159daafdb8c956bd63850c33e5771f5b1ad3 Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Tue, 17 Dec 2024 13:14:19 +0000 Subject: [PATCH] Fix deadlocking on Linux clipboard test (2) --- internal/driver/glfw/window.go | 12 ++++-------- internal/driver/glfw/window_test.go | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/internal/driver/glfw/window.go b/internal/driver/glfw/window.go index 08e04eae9b..12432b153f 100644 --- a/internal/driver/glfw/window.go +++ b/internal/driver/glfw/window.go @@ -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) diff --git a/internal/driver/glfw/window_test.go b/internal/driver/glfw/window_test.go index 64b96e963b..03ff71b450 100644 --- a/internal/driver/glfw/window_test.go +++ b/internal/driver/glfw/window_test.go @@ -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