This PR adds an unbind_extension_point function that reverses the effects of bind_extension_point. In particular, unbind_extension_point removes references to the target HasTraits object from global state, allowing that object to be garbage collected in the usual way. (Previously, those references would live until the end of the process.)
Detailed changes
New unbind_extension_point function (exported via envisage.api), with parameters exactly matching those of bind_extension_point. This undoes listener changes, and removes the binding from the global ExtensionPointBinding._bindings dictionary.
New private ExtensionPointBinding._unbind method that undoes listener changes. The _initialize method has been renamed to _bind to match.
Creation of an ExtensionPointBinding object no longer modifies the global ExtensionPointBinding._bindings dictionary; instead, that mutation of global state is done in bind_extension_point. (At some point in the future, we may want to move this global state somewhere else - perhaps onto the extension registry.)
ExtensionPointBinding._bindings is now a regular Python dict instead of a WeakKeyDictionary: the weak reference functionality never worked in the first place because our dictionary values had a strong reference to the corresponding keys, so there's no need for the additional complication introduced by the use of a WeakKeyDictionary.
This PR adds an
unbind_extension_point
function that reverses the effects ofbind_extension_point
. In particular,unbind_extension_point
removes references to the targetHasTraits
object from global state, allowing that object to be garbage collected in the usual way. (Previously, those references would live until the end of the process.)Detailed changes
unbind_extension_point
function (exported viaenvisage.api
), with parameters exactly matching those ofbind_extension_point
. This undoes listener changes, and removes the binding from the globalExtensionPointBinding._bindings
dictionary.ExtensionPointBinding._unbind
method that undoes listener changes. The_initialize
method has been renamed to_bind
to match.ExtensionPointBinding
object no longer modifies the globalExtensionPointBinding._bindings
dictionary; instead, that mutation of global state is done inbind_extension_point
. (At some point in the future, we may want to move this global state somewhere else - perhaps onto the extension registry.)ExtensionPointBinding._bindings
is now a regular Pythondict
instead of aWeakKeyDictionary
: the weak reference functionality never worked in the first place because our dictionary values had a strong reference to the corresponding keys, so there's no need for the additional complication introduced by the use of aWeakKeyDictionary
.Fixes #97