Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 20c2961

Browse filesBrowse files
committed
Merge pull request #6339 from mdboom/qt4agg-animation
Fix #6335: Queue boxes to update
2 parents ff0012e + 5bde1ff commit 20c2961
Copy full SHA for 20c2961

File tree

Expand file treeCollapse file tree

3 files changed

+25
-22
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+25
-22
lines changed

‎lib/matplotlib/animation.py

Copy file name to clipboardExpand all lines: lib/matplotlib/animation.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ def _handle_resize(self, *args):
10251025
def _end_redraw(self, evt):
10261026
# Now that the redraw has happened, do the post draw flushing and
10271027
# blit handling. Then re-enable all of the original events.
1028-
self._post_draw(None, self._blit)
1028+
self._post_draw(None, False)
10291029
self.event_source.start()
10301030
self._fig.canvas.mpl_disconnect(self._resize_id)
10311031
self._resize_id = self._fig.canvas.mpl_connect('resize_event',

‎lib/matplotlib/backends/backend_qt4agg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt4agg.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(self, figure):
7777
FigureCanvasQTAggBase.__init__(self, figure)
7878
FigureCanvasAgg.__init__(self, figure)
7979
self._drawRect = None
80-
self.blitbox = None
80+
self.blitbox = []
8181
self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent)
8282

8383

‎lib/matplotlib/backends/backend_qt5agg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt5agg.py
+23-20Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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,34 @@ 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
139+
# around a memory leak bug in QImage() under PySide on
140+
# Python 3.x
141+
if QT_API == 'PySide' and six.PY3:
142+
ctypes.c_long.from_address(id(stringBuffer)).value = 1
143+
144+
pixmap = QtGui.QPixmap.fromImage(qImage)
145+
p.drawPixmap(QtCore.QPoint(l, self.renderer.height-t), pixmap)
143146

144147
# draw the zoom rectangle to the QPainter
145148
if self._drawRect is not None:
146149
p.setPen(QtGui.QPen(QtCore.Qt.black, 1, QtCore.Qt.DotLine))
147150
x, y, w, h = self._drawRect
148151
p.drawRect(x, y, w, h)
152+
149153
p.end()
150-
self.blitbox = None
151154

152155
def draw(self):
153156
"""
@@ -190,7 +193,7 @@ def blit(self, bbox=None):
190193
if bbox is None and self.figure:
191194
bbox = self.figure.bbox
192195

193-
self.blitbox = bbox
196+
self.blitbox.append(bbox)
194197
l, b, w, h = bbox.bounds
195198
t = b + h
196199
self.repaint(l, self.renderer.height-t, w, h)
@@ -218,7 +221,7 @@ def __init__(self, figure):
218221
print('FigureCanvasQtAgg: ', figure)
219222
super(FigureCanvasQTAgg, self).__init__(figure=figure)
220223
self._drawRect = None
221-
self.blitbox = None
224+
self.blitbox = []
222225
self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent)
223226

224227

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.