From 1540c98eb91c685f0a15e4de4de3b85611f73194 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sun, 13 Mar 2016 23:14:25 -0400 Subject: [PATCH] FIX: deal with negative canvas dimension in Qt In some cases Qt may report having a negative height (and presumably width) in the case of minimizing windows / widgets. This causes issues at the Agg layer when the re-size triggers a re-draw which tries to get a renderer with a negative dimension (segfaults or OutOfMemory errors). --- lib/matplotlib/backends/backend_qt5agg.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/matplotlib/backends/backend_qt5agg.py b/lib/matplotlib/backends/backend_qt5agg.py index 656c837e5e65..5920ab09c7cf 100644 --- a/lib/matplotlib/backends/backend_qt5agg.py +++ b/lib/matplotlib/backends/backend_qt5agg.py @@ -172,6 +172,9 @@ def draw_idle(self): QtCore.QTimer.singleShot(0, self.__draw_idle_agg) def __draw_idle_agg(self, *args): + if self.height() < 0 or self.width() < 0: + self._agg_draw_pending = False + return try: FigureCanvasAgg.draw(self) self.update()