Skip to content

Commit 16baab9

Browse files
committed
FIX: add check if the renderer exists
There exists a path where paintEvent can be called before the first time that `draw` has been called. This results in an exception because the call to `FigureCanvasAgg.draw(self)` is what create the renderer attribute on the canvas.
1 parent b9bc7d1 commit 16baab9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/matplotlib/backends/backend_qt5agg.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ def paintEvent(self, e):
7575
In Qt, all drawing should be done inside of here when a widget is
7676
shown onscreen.
7777
"""
78-
# FigureCanvasQT.paintEvent(self, e)
78+
# if the canvas does not have a renderer, then give up and wait for
79+
# FigureCanvasAgg.draw(self) to be called
80+
if not hasattr(self, 'renderer'):
81+
return
82+
7983
if DEBUG:
8084
print('FigureCanvasQtAgg.paintEvent: ', self,
8185
self.get_width_height())

0 commit comments

Comments
 (0)