diff --git a/internal/driver/glfw/driver.go b/internal/driver/glfw/driver.go index d9c930ad91..c1acceb1c1 100644 --- a/internal/driver/glfw/driver.go +++ b/internal/driver/glfw/driver.go @@ -33,10 +33,9 @@ var curWindow *window var _ fyne.Driver = (*gLDriver)(nil) type gLDriver struct { - windowLock sync.RWMutex - windows []fyne.Window - done chan struct{} - waitForStart chan struct{} + windowLock sync.RWMutex + windows []fyne.Window + waitForTransition chan struct{} // wait for transitioning first from starting and later on to quiting. animation animation.Runner @@ -99,7 +98,7 @@ func (d *gLDriver) Quit() { // Only call close once to avoid panic. if running.CompareAndSwap(true, false) { - close(d.done) + close(d.waitForTransition) } } @@ -174,7 +173,6 @@ func NewGLDriver() *gLDriver { repository.Register("file", intRepo.NewFileRepository()) return &gLDriver{ - done: make(chan struct{}), - waitForStart: make(chan struct{}), + waitForTransition: make(chan struct{}), } } diff --git a/internal/driver/glfw/glfw_test.go b/internal/driver/glfw/glfw_test.go index 4888ef590a..096fefb272 100644 --- a/internal/driver/glfw/glfw_test.go +++ b/internal/driver/glfw/glfw_test.go @@ -32,10 +32,6 @@ func ensureCanvasSize(t *testing.T, w *window, size fyne.Size) { } func repaintWindow(w *window) { - // Wait for GLFW loop to be running. - // If we try to paint windows before the context is created, we will end up on the wrong thread. - <-w.driver.waitForStart - runOnMainWithContext(w, func() { d.repaintWindow(w) }) diff --git a/internal/driver/glfw/loop.go b/internal/driver/glfw/loop.go index 8d26dbb683..84bbe5a240 100644 --- a/internal/driver/glfw/loop.go +++ b/internal/driver/glfw/loop.go @@ -93,7 +93,9 @@ func (d *gLDriver) runGL() { if !running.CompareAndSwap(false, true) { return // Run was called twice. } - close(d.waitForStart) // Signal that execution can continue. + + close(d.waitForTransition) // Signal that execution can continue. + d.waitForTransition = make(chan struct{}) // Prepare for transitioning into done. d.initGLFW() if d.trayStart != nil { @@ -109,7 +111,7 @@ func (d *gLDriver) runGL() { eventTick := time.NewTicker(time.Second / 60) for { select { - case <-d.done: + case <-d.waitForTransition: eventTick.Stop() d.Terminate() l := fyne.CurrentApp().Lifecycle().(*app.Lifecycle) diff --git a/internal/driver/glfw/window.go b/internal/driver/glfw/window.go index ba23a6cfdf..6261dac79c 100644 --- a/internal/driver/glfw/window.go +++ b/internal/driver/glfw/window.go @@ -140,8 +140,6 @@ func (w *window) doShow() { return } - <-w.driver.waitForStart - w.createLock.Do(w.create) if w.view() == nil { return diff --git a/internal/driver/glfw/window_test.go b/internal/driver/glfw/window_test.go index 626739a22e..bf7d0c28c8 100644 --- a/internal/driver/glfw/window_test.go +++ b/internal/driver/glfw/window_test.go @@ -38,9 +38,6 @@ func init() { func TestMain(m *testing.M) { d.initGLFW() go func() { - // Wait for GLFW loop to be running. - // If we try to create windows before the context is created, this will fail with an exception. - <-d.waitForStart initMainMenu() os.Exit(m.Run())