mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
graphics: Bug fix: Call theImages.add after initializing (#242)
This commit is contained in:
parent
910e1b760c
commit
006f918b8e
11
image.go
11
image.go
@ -203,10 +203,7 @@ func NewImage(width, height int, filter Filter) (*Image, error) {
|
|||||||
height: height,
|
height: height,
|
||||||
filter: filter,
|
filter: filter,
|
||||||
}
|
}
|
||||||
eimg, err := theImages.add(image)
|
var err error
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
image.image, err = graphics.NewImage(width, height, glFilter(filter))
|
image.image, err = graphics.NewImage(width, height, glFilter(filter))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -215,6 +212,10 @@ func NewImage(width, height int, filter Filter) (*Image, error) {
|
|||||||
if err := image.image.Fill(color.Transparent); err != nil {
|
if err := image.image.Fill(color.Transparent); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
eimg, err := theImages.add(image)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return eimg, nil
|
return eimg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,10 +271,10 @@ func newImageWithScreenFramebuffer(width, height int) (*Image, error) {
|
|||||||
height: height,
|
height: height,
|
||||||
screen: true,
|
screen: true,
|
||||||
}
|
}
|
||||||
|
runtime.SetFinalizer(img, (*imageImpl).Dispose)
|
||||||
eimg, err := theImages.add(img)
|
eimg, err := theImages.add(img)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
runtime.SetFinalizer(img, (*imageImpl).Dispose)
|
|
||||||
return eimg, nil
|
return eimg, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user