mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
restorable: Bug fix: Dispose should be deferred between frames (again)
Updates #913
This commit is contained in:
parent
4717baa840
commit
628a8d559a
@ -574,6 +574,17 @@ func (i *Image) restore() error {
|
|||||||
//
|
//
|
||||||
// After disposing, calling the function of the image causes unexpected results.
|
// After disposing, calling the function of the image causes unexpected results.
|
||||||
func (i *Image) Dispose() {
|
func (i *Image) Dispose() {
|
||||||
|
select {
|
||||||
|
case theImages.deferCh <- struct{}{}:
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
theImages.deferUntilBeginFrame(i.Dispose)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
<-theImages.deferCh
|
||||||
|
}()
|
||||||
|
|
||||||
theImages.remove(i)
|
theImages.remove(i)
|
||||||
i.image.Dispose()
|
i.image.Dispose()
|
||||||
i.image = nil
|
i.image = nil
|
||||||
|
Loading…
Reference in New Issue
Block a user