internal/uidriver/glfw: Bug fix: Crash at Restore

This is the same reason as Maximize.

Updates #1576
This commit is contained in:
Hajime Hoshi 2021-04-18 00:10:37 +09:00
parent 37944d67c4
commit d6ab27a5a2
2 changed files with 13 additions and 1 deletions

View File

@ -1308,3 +1308,15 @@ func (u *UserInterface) maximize() {
w, h := u.window.GetSize()
u.setWindowSize(w, h, u.isFullscreen())
}
func (u *UserInterface) restore() {
// Restore invokes the SetSize callback but the callback must not be called in the game's Update (#1576).
if u.unregisterWindowSetSizeCallback() {
defer u.registerWindowSetSizeCallback()
}
u.window.Restore()
// Call setWindowSize explicitly in order to update the rendering since the callback is unregistered now.
w, h := u.window.GetSize()
u.setWindowSize(w, h, u.isFullscreen())
}

View File

@ -170,7 +170,7 @@ func (w *window) Restore() {
return
}
_ = w.ui.t.Call(func() error {
w.ui.window.Restore()
w.ui.restore()
return nil
})
}