Skip to content

Commit

Permalink
FIX: set internal flags first in FigureCanvasBase
Browse files Browse the repository at this point in the history
If interactive mode is on using the model where every time any artist is
invalidated/marked as stale a `draw_idle` is triggered and the user is
using a non-Agg based backend, saving a png will result in a draw_idle
call triggered from inside the __init__ method of `FigureCanvasBase`
which then fails because the full object has not been set up (this is
not a problem using the IPython hooks because the stale state is only
checked once when all user code has completed executing).

closes matplotlib#5094
  • Loading branch information
tacaswell authored and jenshnielsen committed Sep 27, 2015
1 parent 87c9e4d commit 7e644b6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/matplotlib/backend_bases.py
Expand Up @@ -1678,6 +1678,14 @@ class FigureCanvasBase(object):
'Tagged Image File Format')

def __init__(self, figure):
# put this first to make sure that we prevent any attempts to
# re-draw while we are constructing the canvas.
# See issue #5094, this only trigged on saving a png when:
# - using a non-agg backend
# - in interactive mode
# - not bunching `draw_idle` calls (ex not in IPython)
self._is_idle_drawing = True

figure.set_canvas(self)
self.figure = figure
# a dictionary from event name to a dictionary that maps cid->func
Expand Down

0 comments on commit 7e644b6

Please sign in to comment.