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:41:48 +09:00
parent 5f8ef3cf52
commit 0429c9c3e6

View File

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