mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 03:02:49 +01:00
shareable: Bug fix: Don't mark disposed when the image becomes not shared
This commit is contained in:
parent
9efccea31c
commit
03dcd94884
@ -106,7 +106,7 @@ func (i *Image) ensureNotShared() {
|
|||||||
newImg := restorable.NewImage(w, h, false)
|
newImg := restorable.NewImage(w, h, false)
|
||||||
newImg.DrawImage(i.backend.restorable, x, y, x+w, y+h, nil, nil, opengl.CompositeModeCopy, graphics.FilterNearest)
|
newImg.DrawImage(i.backend.restorable, x, y, x+w, y+h, nil, nil, opengl.CompositeModeCopy, graphics.FilterNearest)
|
||||||
|
|
||||||
i.dispose()
|
i.dispose(false)
|
||||||
i.backend = &backend{
|
i.backend = &backend{
|
||||||
restorable: newImg,
|
restorable: newImg,
|
||||||
}
|
}
|
||||||
@ -195,12 +195,14 @@ func (i *Image) At(x, y int) (color.Color, error) {
|
|||||||
func (i *Image) Dispose() {
|
func (i *Image) Dispose() {
|
||||||
backendsM.Lock()
|
backendsM.Lock()
|
||||||
defer backendsM.Unlock()
|
defer backendsM.Unlock()
|
||||||
i.dispose()
|
i.dispose(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Image) dispose() {
|
func (i *Image) dispose(markDisposed bool) {
|
||||||
defer func() {
|
defer func() {
|
||||||
i.disposed = true
|
if markDisposed {
|
||||||
|
i.disposed = true
|
||||||
|
}
|
||||||
i.backend = nil
|
i.backend = nil
|
||||||
i.node = nil
|
i.node = nil
|
||||||
runtime.SetFinalizer(i, nil)
|
runtime.SetFinalizer(i, nil)
|
||||||
|
Loading…
Reference in New Issue
Block a user