From e6ffa5dd632f55d5f834d15e95547dd608a6bf35 Mon Sep 17 00:00:00 2001 From: Nikita Kniazev Date: Sun, 29 Dec 2019 23:03:16 +0300 Subject: [PATCH] Backport PR #16028: Prevent FigureCanvasQT_draw_idle recursively calling itself. --- lib/matplotlib/backends/backend_qt5.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/backends/backend_qt5.py b/lib/matplotlib/backends/backend_qt5.py index f3d1c6459900..b36e6564287b 100644 --- a/lib/matplotlib/backends/backend_qt5.py +++ b/lib/matplotlib/backends/backend_qt5.py @@ -498,17 +498,16 @@ def draw_idle(self): QtCore.QTimer.singleShot(0, self._draw_idle) def _draw_idle(self): - if self.height() < 0 or self.width() < 0: - self._draw_pending = False if not self._draw_pending: return + self._draw_pending = False + if self.height() < 0 or self.width() < 0: + return try: self.draw() except Exception: # Uncaught exceptions are fatal for PyQt5, so catch them instead. traceback.print_exc() - finally: - self._draw_pending = False def drawRectangle(self, rect): # Draw the zoom rectangle to the QPainter. _draw_rect_callback needs