From 7764fda935e329deb26c04b1ec42efb0a65494b3 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 3b5ae14bcef8..4aa4782c96ba 100644 --- a/lib/matplotlib/backends/backend_qt5.py +++ b/lib/matplotlib/backends/backend_qt5.py @@ -481,17 +481,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