From de3b78ee65780c2d2614bcb7d3f464622401f4dd Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Tue, 14 Jun 2022 12:57:55 +0100 Subject: [PATCH] Fix: always clear _draw_called --- matplotlib_inline/backend_inline.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/matplotlib_inline/backend_inline.py b/matplotlib_inline/backend_inline.py index ca2e003..9a53c8b 100644 --- a/matplotlib_inline/backend_inline.py +++ b/matplotlib_inline/backend_inline.py @@ -115,19 +115,20 @@ def flush_figures(): if not show._draw_called: return - if InlineBackend.instance().close_figures: - # ignore the tracking, just draw and close all figures - try: - return show(True) - except Exception as e: - # safely show traceback if in IPython, else raise - ip = get_ipython() - if ip is None: - raise e - else: - ip.showtraceback() - return try: + if InlineBackend.instance().close_figures: + # ignore the tracking, just draw and close all figures + try: + return show(True) + except Exception as e: + # safely show traceback if in IPython, else raise + ip = get_ipython() + if ip is None: + raise e + else: + ip.showtraceback() + return + # exclude any figures that were closed: active = set([fm.canvas.figure for fm in Gcf.get_all_fig_managers()]) for fig in [fig for fig in show._to_draw if fig in active]: