From 0eb217298f8129fb239a2155dc2aa1ba0ec6396c Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Thu, 11 Jun 2020 15:49:01 -0400 Subject: [PATCH 1/2] DOC: correct docstring on start_event_loop Blocks forever of 0 and negative, not just negative closes #17615 --- lib/matplotlib/backend_bases.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 88f74c57b2ef..6b4182f326da 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -2316,7 +2316,7 @@ def start_event_loop(self, timeout=0): The event loop blocks until a callback function triggers `stop_event_loop`, or *timeout* is reached. - If *timeout* is negative, never timeout. + If *timeout* is 0 or negative, never timeout. Only interactive backends need to reimplement this method and it relies on `flush_events` being properly implemented. From 4fb5993651d19074457176e5375997df9012c057 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Thu, 11 Jun 2020 15:49:29 -0400 Subject: [PATCH 2/2] FIX: handle negative timeouts in backend_qt's start_event_loop negative numbers are truthy, only start timer on positive timeouts. --- lib/matplotlib/backends/backend_qt5.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/backends/backend_qt5.py b/lib/matplotlib/backends/backend_qt5.py index 24f0c24fc02a..27c23435f87b 100644 --- a/lib/matplotlib/backends/backend_qt5.py +++ b/lib/matplotlib/backends/backend_qt5.py @@ -426,7 +426,7 @@ def start_event_loop(self, timeout=0): if hasattr(self, "_event_loop") and self._event_loop.isRunning(): raise RuntimeError("Event loop already running") self._event_loop = event_loop = QtCore.QEventLoop() - if timeout: + if timeout > 0: timer = QtCore.QTimer.singleShot(timeout * 1000, event_loop.quit) event_loop.exec_()