Skip to content

Commit c51c132

Browse files
committed
Merge pull request matplotlib#585 from mdboom/multiple_callbacks
macosx backend ignores multiple mpl_connect() calls
2 parents 7a43d25 + 9396ee7 commit c51c132

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lib/matplotlib/cbook.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,21 +264,24 @@ def __init__(self, *args):
264264
DeprecationWarning)
265265
self.callbacks = dict()
266266
self._cid = 0
267-
self._func_cid_map = WeakKeyDictionary()
267+
self._func_cid_map = {}
268268

269269
def connect(self, s, func):
270270
"""
271271
register *func* to be called when a signal *s* is generated
272272
func will be called
273273
"""
274-
if func in self._func_cid_map:
275-
return self._func_cid_map[func]
276-
proxy = self.BoundMethodProxy(func)
274+
self._func_cid_map.setdefault(s, WeakKeyDictionary())
275+
if func in self._func_cid_map[s]:
276+
return self._func_cid_map[s][func]
277+
277278
self._cid += 1
279+
cid = self._cid
280+
self._func_cid_map[s][func] = cid
278281
self.callbacks.setdefault(s, dict())
279-
self.callbacks[s][self._cid] = proxy
280-
self._func_cid_map[func] = self._cid
281-
return self._cid
282+
proxy = self.BoundMethodProxy(func)
283+
self.callbacks[s][cid] = proxy
284+
return cid
282285

283286
def disconnect(self, cid):
284287
"""

0 commit comments

Comments
 (0)