-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Make draggable callbacks check that artist has not been removed. #10908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
lib/matplotlib/offsetbox.py
Outdated
self.finalize_offset() | ||
self.got_artist = False | ||
self.canvas.mpl_disconnect(self._c1) | ||
|
||
if self._use_blit: | ||
self.ref_artist.set_animated(False) | ||
|
||
def _check_still_parented(self): | ||
if self.ref_artist.axes is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should probably check self.ref_artist.figure
too incase there are draggable things at the figure level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
👍 I like this solution much better. |
53f4fb5
to
d5a39f4
Compare
Thoughts about moving away from using weakmethods in callbackregistry (see other thread for arguments)? (note that that has a reasonable deprecation pathway: when we were going to remove a weakmethod from the registry, instead insert a proxy method that emits a warning the next time it's called) |
Want to give more thought to changing away from weakrefs before taking a position, but my bias is to not change. |
@tacaswell FWIW, I just noticed that widgets.py uses its own callback-handling mechanism and just uses strong refs without doing anything special; no one seems to be bothered by that... |
PR Summary
Simpler solution to #10876 (see in particular #10876 (comment)).
PR Checklist