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 implements
on
, and renames all references tocallback
tohandler
.Full backwards compatibility is preserved
Example
Technically,
on
is simply an alias forregister_handler
, previously known adregister_callback
.Explicit Support for Graphical User Interfaces.
In addition, this PR implements "weak references" for all event handlers.
This shouldn't have much effect on your day to day use of Pyblish, but will make a difference in a few small corner cases.
For example, consider this.
As you would expect, once the object is deleted, the handler stops being called. Prior to this PR however,
count["#"]
equalled2
.In practice, this could cause issues when you build a GUI around signals, and register methods within your GUI and then create a new instance of this GUI.
The second instance would reconnect to these signals, leaving the old methods in place, resulting in two calls per method. For each instance of your GUI, the calls would stack up, and off you go.
This PR enables you to build user interfaces that harness the signals produces throughout Pyblish, without worrying about these difficult-to-debug problems.