Add an unbind_extension_point function #546
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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