graphics: image's texture may be nil and this must be considered when disposing

This commit is contained in:
Hajime Hoshi 2016-02-21 01:58:51 +09:00
parent 14e6e4c92b
commit d463e91524

View File

@ -151,10 +151,14 @@ func (i *Image) Dispose() error {
return errors.New("image is already disposed")
}
useGLContext(func(c *opengl.Context) {
i.framebuffer.Dispose(c)
i.framebuffer = nil
i.texture.Dispose(c)
i.texture = nil
if i.framebuffer != nil {
i.framebuffer.Dispose(c)
i.framebuffer = nil
}
if i.texture != nil {
i.texture.Dispose(c)
i.texture = nil
}
})
i.pixels = nil
runtime.SetFinalizer(i, nil)