On my machine using master I can reliably get segfaults using QT5Agg by resizing the window a bunch of times (say order 20). There is no segfault on v2.2.2 Suspect #11712 and/or #8951. (Sorry, not quite sure how to revert those locally to test).
diff --git a/lib/matplotlib/backends/backend_qt5agg.py b/lib/matplotlib/backends/backend_qt5agg.py
index 6e0e964a8..b009187a4 100644
--- a/lib/matplotlib/backends/backend_qt5agg.py
+++ b/lib/matplotlib/backends/backend_qt5agg.py
@@ -48,10 +48,9 @@ class FigureCanvasQTAgg(FigureCanvasAgg, FigureCanvasQT):
[[left, self.renderer.height - (top + height * self._dpi_ratio)],
[left + width * self._dpi_ratio, self.renderer.height - top]])
reg = self.copy_from_bbox(bbox)
- buf = reg.to_string_argb()
+ buf = memoryview(reg)
qimage = QtGui.QImage(
- buf, width * self._dpi_ratio, height * self._dpi_ratio,
- QtGui.QImage.Format_ARGB32)
+ buf, buf.shape[1], buf.shape[0], QtGui.QImage.Format_RGBA8888)
if hasattr(qimage, 'setDevicePixelRatio'):
# Not available on Qt4 or some older Qt5.
qimage.setDevicePixelRatio(self._dpi_ratio)
fix it for you? Basically the problem is that the bbox extents are floats, so there may be an off-by-one difference in rounding to get the image size. Format_RGBA8888 may appear as less efficient but in fact we save a copy by directly taking the underlying renderer buffer in memoryview(reg) so it comes down to the same.
Activity
anntzer commented on Jul 21, 2018
Does
diff --git a/lib/matplotlib/backends/backend_qt5agg.py b/lib/matplotlib/backends/backend_qt5agg.py index 6e0e964a8..b009187a4 100644 --- a/lib/matplotlib/backends/backend_qt5agg.py +++ b/lib/matplotlib/backends/backend_qt5agg.py @@ -48,10 +48,9 @@ class FigureCanvasQTAgg(FigureCanvasAgg, FigureCanvasQT): [[left, self.renderer.height - (top + height * self._dpi_ratio)], [left + width * self._dpi_ratio, self.renderer.height - top]]) reg = self.copy_from_bbox(bbox) - buf = reg.to_string_argb() + buf = memoryview(reg) qimage = QtGui.QImage( - buf, width * self._dpi_ratio, height * self._dpi_ratio, - QtGui.QImage.Format_ARGB32) + buf, buf.shape[1], buf.shape[0], QtGui.QImage.Format_RGBA8888) if hasattr(qimage, 'setDevicePixelRatio'): # Not available on Qt4 or some older Qt5. qimage.setDevicePixelRatio(self._dpi_ratio)fix it for you? Basically the problem is that the bbox extents are floats, so there may be an off-by-one difference in rounding to get the image size. Format_RGBA8888 may appear as less efficient but in fact we save a copy by directly taking the underlying renderer buffer in memoryview(reg) so it comes down to the same.
jklymak commented on Jul 21, 2018
Seems to, at least to the extent that I got bored of resizing the window w/ the GUI well past the point where I could make it die w/o that patch...