Fix #866: remove race condition around context cancel func
This commit is contained in:
@@ -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
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user