Fix #866: remove race condition around context cancel func

This commit is contained in:
Drew Weymouth
2026-03-01 07:41:32 -08:00
parent cfd86b7a1f
commit 12b5d33bbe
+10 -6
View File
@@ -49,12 +49,16 @@ func (i *ThumbnailLoader) Load(coverID string) {
i.OnBeforeLoad() i.OnBeforeLoad()
} }
i.prevLoadCancel = i.im.GetCoverThumbnailAsync(coverID, func(img image.Image, err error) { i.prevLoadCancel = i.im.GetCoverThumbnailAsync(coverID, func(img image.Image, err error) {
if err != nil { fyne.Do(func() {
log.Printf("Error loading cover image: %s", err.Error()) if err != nil {
} else { log.Printf("Error loading cover image: %s", err.Error())
fyne.Do(func() { i.callOnLoaded(img) }) } else {
} i.callOnLoaded(img)
i.prevLoadCancel() // Done. Release resources associated with un-cancelled ctx }
if i.prevLoadCancel != nil {
i.prevLoadCancel() // Cancel the context to release resources if not already cancelled
}
})
}) })
} }