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

Skip to content

Don't bother disconnecting idle_draw at gtk shutdown. #15777

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
Dec 15, 2019

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Nov 26, 2019

If the canvas has already been destroyed this leads to a warning
("Source ID xxx was not found when attempting to remove it").

repro:
MPLBACKEND=gtk3agg python -c 'from pylab import *; fig = plt.figure(); plot(); show(); fig.savefig("/tmp/test.png")'

This may cause an additional call to idle_draw(), but idle_draw() (via
draw()) first checks self.is_drawable() which would return False for
destroyed (thus not visible anymore) widgets
(https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-is-drawable)
so it's just a noop.

Closes #15773.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 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

If the canvas has already been destroyed this leads to a warning
("Source ID xxx was not found when attempting to remove it").

repro:
MPLBACKEND=gtk3agg python -c 'from pylab import *; fig = plt.figure(); plot(); show(); fig.savefig("/tmp/test.png")'

This may cause an additional call to idle_draw(), but idle_draw() (via
draw()) first checks `self.is_drawable()` which would return False for
destroyed (thus not visible anymore) widgets
(https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-is-drawable)
so it's just a noop.
Copy link

@bje- bje- left a comment

Choose a reason for hiding this comment

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

This worked for me.

@tacaswell tacaswell added this to the v3.3.0 milestone Dec 8, 2019
@timhoffm timhoffm merged commit 34734a7 into matplotlib:master Dec 15, 2019
@anntzer anntzer deleted the gtk3-shutdown branch December 15, 2019 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warning:... GLib.source_remove(self._idle_draw_id) when using plt.savefig()
4 participants