From 21e0a2e88b3aa181c278cd2904150d2040350314 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Mon, 17 Apr 2023 23:34:59 -0400 Subject: [PATCH] Remove print_figure overrides in backend subclasses AFAICT, `print_figure` is only called in `savefig`, and thus has no relation to backend drawing. We went through a lot of trouble to make `savefig` self-contained, so if this really had any effect, it would be a bug in it instead. But other backends don't do this override and seem to work fine, so these seem superfluous as well. After this change, just opening a window in Qt and using the save button did not seem to break anything, nor did running `savefig` with an interactive window open. I did not test Wx, but given the callers of `print_figure`, I don't see how it could be different. Fixes #5234 --- lib/matplotlib/backends/backend_qtagg.py | 4 ---- lib/matplotlib/backends/backend_wx.py | 9 --------- 2 files changed, 13 deletions(-) diff --git a/lib/matplotlib/backends/backend_qtagg.py b/lib/matplotlib/backends/backend_qtagg.py index f64264d712f7..f89de8efba97 100644 --- a/lib/matplotlib/backends/backend_qtagg.py +++ b/lib/matplotlib/backends/backend_qtagg.py @@ -71,10 +71,6 @@ def paintEvent(self, event): finally: painter.end() - def print_figure(self, *args, **kwargs): - super().print_figure(*args, **kwargs) - self.draw() - @_BackendQT.export class _BackendQTAgg(_BackendQT): diff --git a/lib/matplotlib/backends/backend_wx.py b/lib/matplotlib/backends/backend_wx.py index 70f0c0fff515..5d7349b8759c 100644 --- a/lib/matplotlib/backends/backend_wx.py +++ b/lib/matplotlib/backends/backend_wx.py @@ -614,15 +614,6 @@ def gui_repaint(self, drawDC=None): 'xpm': 'X pixmap', } - def print_figure(self, filename, *args, **kwargs): - # docstring inherited - super().print_figure(filename, *args, **kwargs) - # Restore the current view; this is needed because the artist contains - # methods rely on particular attributes of the rendered figure for - # determining things like bounding boxes. - if self._isDrawn: - self.draw() - def _on_paint(self, event): """Called when wxPaintEvt is generated.""" _log.debug("%s - _on_paint()", type(self))