diff --git a/internal/driver/glfw/driver.go b/internal/driver/glfw/driver.go index 0b81826a44..ab9cf768a0 100644 --- a/internal/driver/glfw/driver.go +++ b/internal/driver/glfw/driver.go @@ -172,9 +172,11 @@ func (d *gLDriver) Run() { func NewGLDriver() fyne.Driver { repository.Register("file", intRepo.NewFileRepository()) - return &gLDriver{ + d := &gLDriver{ done: make(chan interface{}), drawDone: make(chan interface{}), animation: &animation.Runner{}, } + d.initGLFW() + return d } diff --git a/internal/driver/glfw/loop.go b/internal/driver/glfw/loop.go index 34c5c2ecc4..034917aac1 100644 --- a/internal/driver/glfw/loop.go +++ b/internal/driver/glfw/loop.go @@ -33,7 +33,6 @@ type runFlag struct { var funcQueue = make(chan funcData) var drawFuncQueue = make(chan drawData) var run = &runFlag{Cond: sync.Cond{L: &sync.Mutex{}}} -var initOnce = &sync.Once{} // Arrange that main.main runs on main thread. func init() { @@ -106,7 +105,6 @@ func (d *gLDriver) runGL() { run.L.Unlock() run.Broadcast() - d.initGLFW() if d.trayStart != nil { d.trayStart() } diff --git a/internal/driver/glfw/loop_desktop.go b/internal/driver/glfw/loop_desktop.go index 652e6cf023..37b5aeb640 100644 --- a/internal/driver/glfw/loop_desktop.go +++ b/internal/driver/glfw/loop_desktop.go @@ -12,16 +12,14 @@ import ( ) func (d *gLDriver) initGLFW() { - initOnce.Do(func() { - err := glfw.Init() - if err != nil { - fyne.LogError("failed to initialise GLFW", err) - return - } - - initCursors() - d.startDrawThread() - }) + err := glfw.Init() + if err != nil { + fyne.LogError("failed to initialise GLFW", err) + return + } + + initCursors() + d.startDrawThread() } func (d *gLDriver) tryPollEvents() { diff --git a/internal/driver/glfw/loop_goxjs.go b/internal/driver/glfw/loop_goxjs.go index e5082800ac..8b49b186a3 100644 --- a/internal/driver/glfw/loop_goxjs.go +++ b/internal/driver/glfw/loop_goxjs.go @@ -13,15 +13,13 @@ import ( ) func (d *gLDriver) initGLFW() { - initOnce.Do(func() { - err := glfw.Init(gl.ContextWatcher) - if err != nil { - fyne.LogError("failed to initialise GLFW", err) - return - } + err := glfw.Init(gl.ContextWatcher) + if err != nil { + fyne.LogError("failed to initialise GLFW", err) + return + } - d.startDrawThread() - }) + d.startDrawThread() } func (d *gLDriver) tryPollEvents() { diff --git a/internal/driver/glfw/window.go b/internal/driver/glfw/window.go index 6802dd5bf5..a070052359 100644 --- a/internal/driver/glfw/window.go +++ b/internal/driver/glfw/window.go @@ -947,8 +947,6 @@ func (d *gLDriver) createWindow(title string, decorate bool) fyne.Window { title = defaultTitle } runOnMain(func() { - d.initGLFW() - ret = &window{title: title, decorate: decorate, driver: d} // This queue is destroyed when the window is closed. ret.InitEventQueue()