internal/uidriver/glfw: Bug fix: SEGV at setWindowSize

u.window can be a different value before and after the function
setWindowSize.

Closes #1522
This commit is contained in:
Hajime Hoshi 2021-03-03 23:04:33 +09:00
parent c8b98f13fb
commit fda421c5fe

View File

@ -949,7 +949,11 @@ func (u *UserInterface) setWindowSize(width, height int, fullscreen bool) {
// ForceUpdate is called from the callback. // ForceUpdate is called from the callback.
// While setWindowSize can be called from Update, calling ForceUpdate inside Update is illegal (#1505). // While setWindowSize can be called from Update, calling ForceUpdate inside Update is illegal (#1505).
f := u.window.SetSizeCallback(nil) f := u.window.SetSizeCallback(nil)
defer u.window.SetSizeCallback(f) defer func() {
// u.window can be changed before this deferred function is executed.
// Wrap this call by an anonymous function (#1522).
u.window.SetSizeCallback(f)
}()
var windowRecreated bool var windowRecreated bool