diff --git a/internal/driver/glfw/driver.go b/internal/driver/glfw/driver.go index 23d28dbef5..0cd5870962 100644 --- a/internal/driver/glfw/driver.go +++ b/internal/driver/glfw/driver.go @@ -7,7 +7,6 @@ import ( "image" "os" "runtime" - "sync" "github.com/fyne-io/image/ico" @@ -33,7 +32,6 @@ var curWindow *window var _ fyne.Driver = (*gLDriver)(nil) type gLDriver struct { - windowLock sync.RWMutex windows []fyne.Window done chan struct{} waitForStart chan struct{} @@ -104,8 +102,6 @@ func (d *gLDriver) Quit() { } func (d *gLDriver) addWindow(w *window) { - d.windowLock.Lock() - defer d.windowLock.Unlock() d.windows = append(d.windows, w) } @@ -113,12 +109,8 @@ func (d *gLDriver) addWindow(w *window) { // This may not do the right thing if your app has 3 or more windows open, but it was agreed this was not much // of an issue, and the added complexity to track focus was not needed at this time. func (d *gLDriver) focusPreviousWindow() { - d.windowLock.RLock() - wins := d.windows - d.windowLock.RUnlock() - var chosen *window - for _, w := range wins { + for _, w := range d.windows { win := w.(*window) if !win.visible { continue @@ -136,8 +128,6 @@ func (d *gLDriver) focusPreviousWindow() { } func (d *gLDriver) windowList() []fyne.Window { - d.windowLock.RLock() - defer d.windowLock.RUnlock() return d.windows } diff --git a/internal/driver/glfw/loop.go b/internal/driver/glfw/loop.go index 452a7f422d..8dc57724e4 100644 --- a/internal/driver/glfw/loop.go +++ b/internal/driver/glfw/loop.go @@ -167,9 +167,7 @@ func (d *gLDriver) runGL() { newWindows = append(newWindows, win) } - d.windowLock.Lock() d.windows = newWindows - d.windowLock.Unlock() if len(newWindows) == 0 { d.Quit() diff --git a/internal/driver/glfw/window.go b/internal/driver/glfw/window.go index 1f36b20c34..def454bf22 100644 --- a/internal/driver/glfw/window.go +++ b/internal/driver/glfw/window.go @@ -875,7 +875,6 @@ func (d *gLDriver) CreateWindow(title string) fyne.Window { // handling multiple windows by overlaying on the root for web var root fyne.Window - d.windowLock.RLock() hasVisible := false for _, w := range d.windows { if w.(*window).visible { @@ -884,7 +883,6 @@ func (d *gLDriver) CreateWindow(title string) fyne.Window { break } } - d.windowLock.RUnlock() if !hasVisible { return d.createWindow(title, true) diff --git a/internal/driver/glfw/window_test.go b/internal/driver/glfw/window_test.go index e18d5d960d..a45544370e 100644 --- a/internal/driver/glfw/window_test.go +++ b/internal/driver/glfw/window_test.go @@ -1678,8 +1678,11 @@ func TestWindow_SetFullScreen(t *testing.T) { // } func createWindow(title string) fyne.Window { - w := d.CreateWindow(title) - w.(*window).create() + var w fyne.Window + runOnMain(func() { + w = d.CreateWindow(title) + w.(*window).create() + }) return w }