From 04a2d1149063b4ebe966092dcd4f8473fb0cb264 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 6 Sep 2019 23:25:22 +0100 Subject: [PATCH] Backport PR #15206: FIX: be more forgiving about expecting internal state in draw_idle Merge pull request #15206 from tacaswell/fix_python_ion_second_qtcanvas_init FIX: be more forgiving about expecting internal state in draw_idle Conflicts: lib/matplotlib/tests/test_backend_qt.py - no tests on this branch, did not backport test --- lib/matplotlib/backends/backend_qt5.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/backends/backend_qt5.py b/lib/matplotlib/backends/backend_qt5.py index f70bf6f1dc5f..7295ba1e8e22 100644 --- a/lib/matplotlib/backends/backend_qt5.py +++ b/lib/matplotlib/backends/backend_qt5.py @@ -506,7 +506,8 @@ def draw_idle(self): # current event loop in order to ensure thread affinity and to # accumulate multiple draw requests from event handling. # TODO: queued signal connection might be safer than singleShot - if not (self._draw_pending or self._is_drawing): + if not (getattr(self, '_draw_pending', False) or + getattr(self, '._is_drawing', False)): self._draw_pending = True QtCore.QTimer.singleShot(0, self._draw_idle)