SourceForge logo
SourceForge logo
Menu

Re: [matplotlib-devel] Event handling broken in svn?

From: Fernando P. <fpe...@gm...> - 2010年10月01日 18:02:07
Hey Ryan,
On Fri, Oct 1, 2010 at 6:27 AM, Ryan May <rm...@gm...> wrote:
> On Fri, Oct 1, 2010 at 1:05 AM, Fernando Perez <fpe...@gm...> wrote:
>> This manifested itself in some more complex MPL code that had multiple
>> events not working when run inside ipython, but working OK outside of
>> ipython. Fortunately, the small self-contained example demonstrates
>> the problem even with ipython not being in the picture at all (the
>> runs above were from the command line), so I think there is an issue
>> in MPL proper.
>>
>> Sorry that I can't dig deeper into the code right now to look for a fix...
>
> Somewhere in the 1.0 development cycle, Michael modified the callback
> code to take weak references to methods. The purpose was to eliminate
> some "leaks" that were occurring because callback connections to
> objects were keeping them around and the proper disconnects were not
> made (much simpler fix than tracking down every mpl_connect and trying
> to see where do disconnect). What you're seeing in your script is that
> since you're not assigning the Handler object to anything, it's being
> garbage collected. It works for me if I change the second to last line
> to:
>
>  h = Handler(f)
Many thanks for the info, that helps a lot.
I was wondering though, would we still have a leak if strong
references are held in the canvas attribute? The canvas will be
deleted when the figure goes away, so that should properly allow the
callback references to be deleted, without deleting them early
otherwise, no?
In any case, if my logic is flawed (quite likely, since I imagine M.
D. had a good look at this), it might be worth adding a
.. warning::
section about this pattern to the event docs:
http://matplotlib.sourceforge.net/users/event_handling.html
because the problem is subtle and hard to diagnose (I just noticed it
had also been reported recently
http://sourceforge.net/mailarchive/forum.php?thread_name=4C9B7793.5020908%40gmail.com&forum_name=matplotlib-devel).
In any case, thanks again for the help!
Cheers,
f

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /