graphics: Bug fix: Call theImages.add after initializing (#242)

This commit is contained in:
Hajime Hoshi 2016-07-04 23:41:57 +09:00
parent 910e1b760c
commit 006f918b8e

View File

@ -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
} }