From 7a51cac5fd6fbfec1d7aff37e4d3618c252e1847 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Thu, 26 Dec 2019 23:31:38 +0100 Subject: [PATCH] Prevent FigureCanvasQT_draw_idle recursively calling itself. Avoids an infinite loop in examples/event_handling/path_editor.py. The logic is now similar to the one before 984fba1. --- 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 7f5d214ac1d5..f59440eff7e0 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