From 697c9094e0fc034a291102a72d4c139765ae0d69 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 13 May 2015 23:01:02 -0400 Subject: [PATCH] FIX : hide ref counting violence unless needed Hide the violence added in 078ddc179ca1656b6dc023604d26b0dc076f49d2 to ref counting on temporary QImage objects which prevents a memory leak under PySide and py3k. This seems to break blitting under PyQt4 and python3 resulting in a *** Error in `python': corrupted double-linked list: 0x00000000024a9940 *** error which kills the gui. --- lib/matplotlib/backends/backend_qt5agg.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/backends/backend_qt5agg.py b/lib/matplotlib/backends/backend_qt5agg.py index b52c771cce5c..af5427299e2b 100644 --- a/lib/matplotlib/backends/backend_qt5agg.py +++ b/lib/matplotlib/backends/backend_qt5agg.py @@ -23,7 +23,7 @@ from .backend_qt5 import draw_if_interactive from .backend_qt5 import backend_version ###### - +from .qt_compat import QT_API DEBUG = False @@ -127,7 +127,8 @@ def paintEvent(self, e): QtGui.QImage.Format_ARGB32) # Adjust the stringBuffer reference count to work around a memory # leak bug in QImage() under PySide on Python 3.x - ctypes.c_long.from_address(id(stringBuffer)).value = 1 + if QT_API == 'PySide' and six.PY3: + ctypes.c_long.from_address(id(stringBuffer)).value = 1 pixmap = QtGui.QPixmap.fromImage(qImage) p = QtGui.QPainter(self)