Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

A disconnected callback cannot be reconnected #1630

Merged
merged 1 commit into from

2 participants

@anntzer

Consider the following example:

import matplotlib.pyplot as plt
fig, ax = plt.subplots()
p = lambda event: print(event)
cid = fig.canvas.mpl_connect("button_press_event", p)
print("connection", cid)
if __debug__:
    print("disconnect, reconnect")
    fig.canvas.mpl_disconnect(cid)
    cid = fig.canvas.mpl_connect("button_press_event", p)
    print("connection", cid)
plt.show()

One would expect the callback to be connected whether __debug__ is True or False, but in fact after the disconnection and reconnection, nothing happens anymore on button press.

@mdboom mdboom merged commit 78fa072 into matplotlib:v1.2.x
@toddrjen toddrjen referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@mdboom mdboom deleted the mdboom:reconnect_callbacks branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 2, 2013
  1. @mdboom
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 3 deletions.
  1. +4 −3 lib/matplotlib/cbook.py
View
7 lib/matplotlib/cbook.py
@@ -323,9 +323,10 @@ def disconnect(self, cid):
except KeyError:
continue
else:
- for key, value in self._func_cid_map.items():
- if value == cid:
- del self._func_cid_map[key]
+ for category, functions in self._func_cid_map.items():
+ for function, value in functions.items():
+ if value == cid:
+ del functions[function]
return
def process(self, s, *args, **kwargs):
Something went wrong with that request. Please try again.