internal/ui: catch an error at At at updateIconIfNeeded

Closes #2647
This commit is contained in:
Hajime Hoshi 2023-04-20 00:56:08 +09:00
parent dd393b6f21
commit b40c5b1e99
5 changed files with 19 additions and 7 deletions

View File

@ -147,7 +147,9 @@ func (c *context) updateFrameImpl(graphicsDriver graphicsdriver.Graphics, update
// Update window icons during a frame, since an icon might be *ebiten.Image and // Update window icons during a frame, since an icon might be *ebiten.Image and
// getting pixels from it needs to be in a frame (#1468). // getting pixels from it needs to be in a frame (#1468).
ui.updateIconIfNeeded() if err := ui.updateIconIfNeeded(); err != nil {
return err
}
// Draw the game. // Draw the game.
if err := c.drawGame(graphicsDriver, forceDraw); err != nil { if err := c.drawGame(graphicsDriver, forceDraw); err != nil {

View File

@ -1113,15 +1113,15 @@ func (u *userInterfaceImpl) updateGame() error {
return nil return nil
} }
func (u *userInterfaceImpl) updateIconIfNeeded() { func (u *userInterfaceImpl) updateIconIfNeeded() error {
// In the fullscreen mode, SetIcon fails (#1578). // In the fullscreen mode, SetIcon fails (#1578).
if u.isFullscreen() { if u.isFullscreen() {
return return nil
} }
imgs := u.getIconImages() imgs := u.getIconImages()
if len(imgs) == 0 { if len(imgs) == 0 {
return return nil
} }
u.setIconImages(nil) u.setIconImages(nil)
@ -1142,9 +1142,16 @@ func (u *userInterfaceImpl) updateIconIfNeeded() {
newImgs[i] = rgba newImgs[i] = rgba
} }
// Catch a possible error at 'At' (#2647).
if err := theGlobalState.error(); err != nil {
return err
}
u.mainThread.Call(func() { u.mainThread.Call(func() {
u.window.SetIcon(newImgs) u.window.SetIcon(newImgs)
}) })
return nil
} }
func (u *userInterfaceImpl) swapBuffersOnRenderThread() { func (u *userInterfaceImpl) swapBuffersOnRenderThread() {

View File

@ -723,7 +723,8 @@ func (u *userInterfaceImpl) beginFrame() {
func (u *userInterfaceImpl) endFrame() { func (u *userInterfaceImpl) endFrame() {
} }
func (u *userInterfaceImpl) updateIconIfNeeded() { func (u *userInterfaceImpl) updateIconIfNeeded() error {
return nil
} }
func IsScreenTransparentAvailable() bool { func IsScreenTransparentAvailable() bool {

View File

@ -457,7 +457,8 @@ func (u *userInterfaceImpl) beginFrame() {
func (u *userInterfaceImpl) endFrame() { func (u *userInterfaceImpl) endFrame() {
} }
func (u *userInterfaceImpl) updateIconIfNeeded() { func (u *userInterfaceImpl) updateIconIfNeeded() error {
return nil
} }
func IsScreenTransparentAvailable() bool { func IsScreenTransparentAvailable() bool {

View File

@ -201,7 +201,8 @@ func (u *userInterfaceImpl) beginFrame() {
func (u *userInterfaceImpl) endFrame() { func (u *userInterfaceImpl) endFrame() {
} }
func (u *userInterfaceImpl) updateIconIfNeeded() { func (u *userInterfaceImpl) updateIconIfNeeded() error {
return nil
} }
func IsScreenTransparentAvailable() bool { func IsScreenTransparentAvailable() bool {