From 913824bebad87656b8a8c879d82f5f0bd28e8a2f Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 19 Oct 2023 12:14:54 +0900 Subject: [PATCH] internal/atlas: close channels on the sender side just in case --- internal/atlas/image.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/atlas/image.go b/internal/atlas/image.go index 912b4b602..ccb20e0cb 100644 --- a/internal/atlas/image.go +++ b/internal/atlas/image.go @@ -547,7 +547,10 @@ func (i *Image) ReadPixels(graphicsDriver graphicsdriver.Graphics, pixels []byte ch := make(chan error) deferredM.Lock() 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() return ch @@ -558,7 +561,10 @@ func (i *Image) ReadPixels(graphicsDriver graphicsdriver.Graphics, pixels []byte flushDeferred() 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 }