graphics: Remove SetFinalizer at Image

Package shareable should take care of this.

Finalizers are called at arbitrary timing in a different goroutine
and might cause tough problems. This might be related to #821.
This commit is contained in:
Hajime Hoshi 2019-02-22 11:08:19 +09:00
parent f19d7a29b8
commit 5195161253

View File

@ -19,7 +19,6 @@ import (
"image" "image"
"image/color" "image/color"
"math" "math"
"runtime"
"sync/atomic" "sync/atomic"
"github.com/hajimehoshi/ebiten/internal/graphics" "github.com/hajimehoshi/ebiten/internal/graphics"
@ -639,7 +638,6 @@ func (i *Image) Dispose() error {
} }
i.mipmap.dispose() i.mipmap.dispose()
i.resolvePixelsToSet(false) i.resolvePixelsToSet(false)
runtime.SetFinalizer(i, nil)
return nil return nil
} }
@ -724,7 +722,6 @@ func NewImage(width, height int, filter Filter) (*Image, error) {
filter: filter, filter: filter,
} }
i.addr = i i.addr = i
runtime.SetFinalizer(i, (*Image).Dispose)
return i, nil return i, nil
} }
@ -766,7 +763,6 @@ func NewImageFromImage(source image.Image, filter Filter) (*Image, error) {
filter: filter, filter: filter,
} }
i.addr = i i.addr = i
runtime.SetFinalizer(i, (*Image).Dispose)
_ = i.ReplacePixels(graphics.CopyImage(source)) _ = i.ReplacePixels(graphics.CopyImage(source))
return i, nil return i, nil
@ -778,7 +774,6 @@ func newImageWithScreenFramebuffer(width, height int) *Image {
filter: FilterDefault, filter: FilterDefault,
} }
i.addr = i i.addr = i
runtime.SetFinalizer(i, (*Image).Dispose)
return i return i
} }