Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f25acff

Browse files
dopplershifttacaswell
authored andcommitted
Fix infinite recursion.
This was introduced by #4800. We need to disconnect the initial draw callback in _start() before doing _init_draw(), otherwise, we end up back in _start() when the draw_event fires. Also go ahead and remove the call to _init_draw() in __init__(), since _start() will handle it.
1 parent 9bf6550 commit f25acff

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/matplotlib/animation.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -590,9 +590,6 @@ def __init__(self, fig, event_source=None, blit=False):
590590
self.frame_seq = self.new_frame_seq()
591591
self.event_source = event_source
592592

593-
# Clear the initial frame
594-
self._init_draw()
595-
596593
# Instead of starting the event source now, we connect to the figure's
597594
# draw_event, so that we only start once the figure has been drawn.
598595
self._first_draw_id = fig.canvas.mpl_connect('draw_event', self._start)
@@ -609,15 +606,18 @@ def _start(self, *args):
609606
Starts interactive animation. Adds the draw frame command to the GUI
610607
handler, calls show to start the event loop.
611608
'''
612-
# On start, we add our callback for stepping the animation and
613-
# actually start the event_source. We also disconnect _start
614-
# from the draw_events
615-
self.event_source.add_callback(self._step)
616-
self._init_draw()
617-
self.event_source.start()
609+
# First disconnect our draw event handler
618610
self._fig.canvas.mpl_disconnect(self._first_draw_id)
619611
self._first_draw_id = None # So we can check on save
620612

613+
# Now do any initial draw
614+
self._init_draw()
615+
616+
# Add our callback for stepping the animation and
617+
# actually start the event_source.
618+
self.event_source.add_callback(self._step)
619+
self.event_source.start()
620+
621621
def _stop(self, *args):
622622
# On stop we disconnect all of our events.
623623
if self._blit:

0 commit comments

Comments
 (0)