mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-13 20:42:07 +01:00
shareable: Bug fix: Double free
This commit is contained in:
parent
6687ffe8ba
commit
693116ffd6
@ -156,6 +156,9 @@ func (i *Image) forceShared() {
|
|||||||
newI.replacePixels(pixels)
|
newI.replacePixels(pixels)
|
||||||
i.dispose(false)
|
i.dispose(false)
|
||||||
*i = *newI
|
*i = *newI
|
||||||
|
// TODO: This is a very tricky hack not to call Dispose twice for the same backend.
|
||||||
|
// Avoid such hack.
|
||||||
|
runtime.SetFinalizer(newI, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Image) region() (x, y, width, height int) {
|
func (i *Image) region() (x, y, width, height int) {
|
||||||
|
@ -18,6 +18,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"image/color"
|
"image/color"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten"
|
"github.com/hajimehoshi/ebiten"
|
||||||
@ -183,4 +184,6 @@ func TestReshared(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runtime.GC()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user