@@ -84,7 +84,7 @@ def paintEvent(self, e):
8484 print ('FigureCanvasQtAgg.paintEvent: ' , self ,
8585 self .get_width_height ())
8686
87- if self .blitbox is None :
87+ if len ( self .blitbox ) == 0 :
8888 # matplotlib is in rgba byte order. QImage wants to put the bytes
8989 # into argb format and is in a 4 byte unsigned int. Little endian
9090 # system is LSB first and expects the bytes in reverse order
@@ -123,31 +123,33 @@ def paintEvent(self, e):
123123 if refcnt != sys .getrefcount (stringBuffer ):
124124 _decref (stringBuffer )
125125 else :
126- bbox = self .blitbox
127- l , b , r , t = bbox .extents
128- w = int (r ) - int (l )
129- h = int (t ) - int (b )
130- t = int (b ) + h
131- reg = self .copy_from_bbox (bbox )
132- stringBuffer = reg .to_string_argb ()
133- qImage = QtGui .QImage (stringBuffer , w , h ,
134- QtGui .QImage .Format_ARGB32 )
135- # Adjust the stringBuffer reference count to work around a memory
136- # leak bug in QImage() under PySide on Python 3.x
137- if QT_API == 'PySide' and six .PY3 :
138- ctypes .c_long .from_address (id (stringBuffer )).value = 1
139-
140- pixmap = QtGui .QPixmap .fromImage (qImage )
141126 p = QtGui .QPainter (self )
142- p .drawPixmap (QtCore .QPoint (l , self .renderer .height - t ), pixmap )
127+
128+ while len (self .blitbox ):
129+ bbox = self .blitbox .pop ()
130+ l , b , r , t = bbox .extents
131+ w = int (r ) - int (l )
132+ h = int (t ) - int (b )
133+ t = int (b ) + h
134+ reg = self .copy_from_bbox (bbox )
135+ stringBuffer = reg .to_string_argb ()
136+ qImage = QtGui .QImage (stringBuffer , w , h ,
137+ QtGui .QImage .Format_ARGB32 )
138+ # Adjust the stringBuffer reference count to work around a memory
139+ # leak bug in QImage() under PySide on Python 3.x
140+ if QT_API == 'PySide' and six .PY3 :
141+ ctypes .c_long .from_address (id (stringBuffer )).value = 1
142+
143+ pixmap = QtGui .QPixmap .fromImage (qImage )
144+ p .drawPixmap (QtCore .QPoint (l , self .renderer .height - t ), pixmap )
143145
144146 # draw the zoom rectangle to the QPainter
145147 if self ._drawRect is not None :
146148 p .setPen (QtGui .QPen (QtCore .Qt .black , 1 , QtCore .Qt .DotLine ))
147149 x , y , w , h = self ._drawRect
148150 p .drawRect (x , y , w , h )
151+
149152 p .end ()
150- self .blitbox = None
151153
152154 def draw (self ):
153155 """
@@ -190,7 +192,7 @@ def blit(self, bbox=None):
190192 if bbox is None and self .figure :
191193 bbox = self .figure .bbox
192194
193- self .blitbox = bbox
195+ self .blitbox . append ( bbox )
194196 l , b , w , h = bbox .bounds
195197 t = b + h
196198 self .repaint (l , self .renderer .height - t , w , h )
@@ -218,7 +220,7 @@ def __init__(self, figure):
218220 print ('FigureCanvasQtAgg: ' , figure )
219221 super (FigureCanvasQTAgg , self ).__init__ (figure = figure )
220222 self ._drawRect = None
221- self .blitbox = None
223+ self .blitbox = []
222224 self .setAttribute (QtCore .Qt .WA_OpaquePaintEvent )
223225
224226
0 commit comments