Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 1 commit into from
Jun 30, 2018

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Mar 28, 2018

PR Summary

Simpler solution to #10876 (see in particular #10876 (comment)).

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzer anntzer added this to the v3.0 milestone Mar 28, 2018
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:
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@tacaswell
Copy link
Member

👍 I like this solution much better.

@anntzer anntzer force-pushed the callback-check-parented branch from 53f4fb5 to d5a39f4 Compare March 28, 2018 08:11
@anntzer
Copy link
Contributor Author

anntzer commented Mar 28, 2018

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)

@tacaswell
Copy link
Member

Want to give more thought to changing away from weakrefs before taking a position, but my bias is to not change.

@tacaswell tacaswell merged commit 2474b37 into matplotlib:master Jun 30, 2018
@anntzer anntzer deleted the callback-check-parented branch June 30, 2018 15:39
@anntzer
Copy link
Contributor Author

anntzer commented Nov 12, 2018

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants