internal/atlas: close channels on the sender side just in case

This commit is contained in:
Hajime Hoshi 2023-10-19 12:14:54 +09:00
parent ad51e22252
commit 913824beba

View File

@ -547,7 +547,10 @@ func (i *Image) ReadPixels(graphicsDriver graphicsdriver.Graphics, pixels []byte
ch := make(chan error) ch := make(chan error)
deferredM.Lock() deferredM.Lock()
deferred = append(deferred, func() { deferred = append(deferred, func() {
ch <- i.readPixels(graphicsDriver, pixels, region) if err := i.readPixels(graphicsDriver, pixels, region); err != nil {
ch <- err
}
close(ch)
}) })
deferredM.Unlock() deferredM.Unlock()
return ch return ch
@ -558,7 +561,10 @@ func (i *Image) ReadPixels(graphicsDriver graphicsdriver.Graphics, pixels []byte
flushDeferred() flushDeferred()
ch := make(chan error, 1) ch := make(chan error, 1)
ch <- i.readPixels(graphicsDriver, pixels, region) if err := i.readPixels(graphicsDriver, pixels, region); err != nil {
ch <- err
}
close(ch)
return ch return ch
} }