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

Skip to content

Commit 51cf15b

Browse files
committed
Merge pull request #4377 from mfitzp/pyside-cursor-memory-leak
FIX : memory leak for Cursor usblit=True on PySide/Python3 @tacaswell fixed up whitespace and merged locally
2 parents 311393a + 4bf42a0 commit 51cf15b

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,7 @@ def paintEvent(self, e):
7575
# FigureCanvasQT.paintEvent(self, e)
7676
if DEBUG:
7777
print('FigureCanvasQtAgg.paintEvent: ', self,
78-
self.get_width_height())
78+
self.get_width_height())
7979

8080
if self.blitbox is None:
8181
# matplotlib is in rgba byte order. QImage wants to put the bytes
@@ -125,6 +125,10 @@ def paintEvent(self, e):
125125
stringBuffer = reg.to_string_argb()
126126
qImage = QtGui.QImage(stringBuffer, w, h,
127127
QtGui.QImage.Format_ARGB32)
128+
# Adjust the stringBuffer reference count to work around a memory
129+
# leak bug in QImage() under PySide on Python 3.x
130+
ctypes.c_long.from_address(id(stringBuffer)).value = 1
131+
128132
pixmap = QtGui.QPixmap.fromImage(qImage)
129133
p = QtGui.QPainter(self)
130134
p.drawPixmap(QtCore.QPoint(l, self.renderer.height-t), pixmap)

0 commit comments

Comments
 (0)