mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
buffered: Bug fix: Race condition at checkDealeydCommandsNil
This change also renames checkDealeydCommandsNil to checkDealeydCommandsFlushed, which makes more sense. Updates #1195
This commit is contained in:
parent
2869885816
commit
0beddf5519
@ -89,8 +89,8 @@ func tryAddDelayedCommandSlow(f func(obj interface{}) error, ondelayed func() in
|
||||
}
|
||||
}
|
||||
|
||||
func checkDelayedCommandsNil(fname string) {
|
||||
if delayedCommands != nil {
|
||||
func checkDelayedCommandsFlushed(fname string) {
|
||||
if atomic.LoadUint32(&delayedCommandsFlushed) == 0 {
|
||||
panic("buffered: the command queue is not available yet at " + fname)
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ func (i *Image) MarkDisposed() {
|
||||
}
|
||||
|
||||
func (img *Image) Pixels(x, y, width, height int) (pix []byte, err error) {
|
||||
checkDelayedCommandsNil("Pixels")
|
||||
checkDelayedCommandsFlushed("Pixels")
|
||||
|
||||
if !image.Rect(x, y, x+width, y+height).In(image.Rect(0, 0, img.width, img.height)) {
|
||||
return nil, fmt.Errorf("buffered: out of range")
|
||||
@ -160,7 +160,7 @@ func (img *Image) Pixels(x, y, width, height int) (pix []byte, err error) {
|
||||
}
|
||||
|
||||
func (i *Image) Dump(name string, blackbg bool) error {
|
||||
checkDelayedCommandsNil("Dump")
|
||||
checkDelayedCommandsFlushed("Dump")
|
||||
return i.img.Dump(name, blackbg)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user