You're absolutely right that it needs to be fixed. However, I wonder why the CallbackRegistry doesn't just store the callbacks in a set (or keys of a dictionary) such that multiple adds of the exact same function or method to the same signal couldn't occur. Since there is no external state stored with each callback, I don't see a need for there ever being more than one of the same thing in there... but maybe I'm missing something. Additionally, it seems like a C-ism to have to deal with callback ids when the callback objects themselves are already hashable and could be used to remove themselves.
Cheers, Mike Stan West wrote: > Quoting John Hunter: > > >> Alternatively you can connect to the figure dpi_changed event -- there is >> an example in Axes.cla >> > > Regarding that example, each call to Axes.cla connects a new dpi_changed > callback, but, as far as I can tell, the callback is never disconnected. > Thus, each cla call augments the dict of dpi_changed figure callbacks: > > fig = figure() > ax = fig.add_subplot(1, 1, 1) > print len(fig.callbacks.callbacks['dpi_changed']) # only 1 > for n in range(7): ax.cla() > print len(fig.callbacks.callbacks['dpi_changed']) # now 8 > > Should cla store the connection id and, if there is a stored id from a prior > call, disconnect the previous callback before connecting the new one? > > Stan > > > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel