Skip to content

Commit

Permalink
Merge pull request #4177 from Jacalz/init-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacalz authored Aug 23, 2023
2 parents 6f3bf59 + 460fa8d commit d2a24a9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 23 deletions.
4 changes: 3 additions & 1 deletion internal/driver/glfw/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 0 additions & 2 deletions internal/driver/glfw/loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -106,7 +105,6 @@ func (d *gLDriver) runGL() {
run.L.Unlock()
run.Broadcast()

d.initGLFW()
if d.trayStart != nil {
d.trayStart()
}
Expand Down
18 changes: 8 additions & 10 deletions internal/driver/glfw/loop_desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
14 changes: 6 additions & 8 deletions internal/driver/glfw/loop_goxjs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 0 additions & 2 deletions internal/driver/glfw/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit d2a24a9

Please sign in to comment.