Skip to content
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

made idle_event() in backend_bases.py return True #3769

Merged
merged 1 commit into from
Nov 9, 2014
Merged

made idle_event() in backend_bases.py return True #3769

merged 1 commit into from
Nov 9, 2014

Conversation

ahaldane
Copy link
Contributor

@ahaldane ahaldane commented Nov 9, 2014

When using the GtkAgg backend I get the following message every time I close a figure in interactive mode:

/usr/lib/python2.7/site-packages/matplotlib/backends/backend_gtk.py:253: Warning: Source ID 31 was not found when attempting to remove it
    gobject.source_remove(self._idle_event_id)

This is because, as documented here, the idle event will be removed if the idle event callback returns false. In this case, the idle_event function had no return value (None) which was equivalent to false, so it was immediately removed. When the backend then tried to remove the event upon figure destruction there was a problem. Making idle_event return True solves this problem for me.

Note that this means that previously callbacks attached to idle_event would not work, since self.callbacks.process(s, event) was not being called after the first idle event.

I am running gtk 2.24.25 and pyGtk 2.24.0-5.

@tacaswell tacaswell added this to the v1.5.x milestone Nov 9, 2014
@tacaswell
Copy link
Member

What impact will this have on other backends?

@ahaldane
Copy link
Contributor Author

ahaldane commented Nov 9, 2014

I tested gtk, qt, tk and wx and they all work fine with the change.

From grepping for 'idle_event' and some testing, it appears that the gtk and wx backends are the only ones that call idle_event, and gtk/gtk3 is the only one that uses the function as a callback (wx calls it directly from its own callback). So I am fairly certain only gtk is affected.

Also, I checked that no other callbacks require a similar change. Looking at the gtk docs the only two event callbacks that need to return true are idle and timeout, and Matplotlib does not use timeout.

tacaswell added a commit that referenced this pull request Nov 9, 2014
BUG/API : made idle_event() in backend_bases.py return True
@tacaswell tacaswell merged commit a9767f7 into matplotlib:master Nov 9, 2014
@tacaswell
Copy link
Member

Great. Thanks for the fix.

Although this is technically an API change, I can't think of anything this could break (yes https://xkcd.com/1172/), so I am not going to worry about an api_changes entry for this.

I can't think of anyway to test this either.

@ahaldane
Copy link
Contributor Author

A little follow-up: I noticed this solves issue 959

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.

3 participants