// Destroy finalizes the value and releases any resources used. // The value must not be used after calling this method. func (obj *Common) Destroy() { // TODO We might hook into the destroyed signal, and prevent this object // from being used in post-destruction crash-prone ways. gui(func() { if obj.addr != nilPtr { C.delObjectLater(obj.addr) obj.addr = nilPtr } }) }
// Destroy finalizes the engine and releases any resources used. // The engine must not be used after calling this method. // // It is safe to call Destroy more than once. func (e *Engine) Destroy() { if !e.destroyed { gui(func() { if !e.destroyed { e.destroyed = true C.delObjectLater(e.addr) if len(e.values) == 0 { delete(engines, e.addr) } else { // The engine reference keeps those values alive. // The last value destroyed will clear it. } stats.enginesAlive(-1) } }) } }