Skip to content

Commit 652478d

Browse files
authored
Merge pull request #14108 from anntzer/macinvalidate
Deprecate FigureCanvasMac.invalidate in favor of draw_idle.
2 parents aaea1d4 + aefc987 commit 652478d

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Deprecations
2+
````````````
3+
4+
``FigureCanvasMac.invalidate`` is deprecated in favor of its synonym,
5+
``FigureCanvasMac.draw_idle``.

lib/matplotlib/backends/backend_macosx.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
TimerBase)
77

88
from matplotlib.figure import Figure
9-
from matplotlib import rcParams
9+
from matplotlib import cbook, rcParams
1010

1111
from matplotlib.widgets import SubplotTool
1212

@@ -83,15 +83,17 @@ def _draw(self):
8383

8484
def draw(self):
8585
# docstring inherited
86-
self.invalidate()
86+
self.draw_idle()
8787
self.flush_events()
8888

89-
def draw_idle(self, *args, **kwargs):
90-
# docstring inherited
91-
self.invalidate()
89+
# draw_idle is provided by _macosx.FigureCanvas
90+
91+
@cbook.deprecated("3.2", alternative="draw_idle()")
92+
def invalidate(self):
93+
return self.draw_idle()
9294

9395
def blit(self, bbox=None):
94-
self.invalidate()
96+
self.draw_idle()
9597

9698
def resize(self, width, height):
9799
dpi = self.figure.dpi
@@ -182,12 +184,7 @@ class _BackendMac(_Backend):
182184

183185
@staticmethod
184186
def trigger_manager_draw(manager):
185-
# For performance reasons, we don't want to redraw the figure after
186-
# each draw command. Instead, we mark the figure as invalid, so that it
187-
# will be redrawn as soon as the event loop resumes via PyOS_InputHook.
188-
# This function should be called after each draw event, even if
189-
# matplotlib is not running interactively.
190-
manager.canvas.invalidate()
187+
manager.canvas.draw_idle()
191188

192189
@staticmethod
193190
def mainloop():

src/_macosx.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
384384
}
385385

386386
static PyObject*
387-
FigureCanvas_invalidate(FigureCanvas* self)
387+
FigureCanvas_draw_idle(FigureCanvas* self)
388388
{
389389
View* view = self->view;
390390
if(!view)
@@ -596,12 +596,12 @@ static CGFloat _get_device_scale(CGContextRef cr)
596596
{"draw",
597597
(PyCFunction)FigureCanvas_draw,
598598
METH_NOARGS,
599-
"Draws the canvas."
599+
NULL, // docstring inherited.
600600
},
601-
{"invalidate",
602-
(PyCFunction)FigureCanvas_invalidate,
601+
{"draw_idle",
602+
(PyCFunction)FigureCanvas_draw_idle,
603603
METH_NOARGS,
604-
"Invalidates the canvas."
604+
NULL, // docstring inherited.
605605
},
606606
{"flush_events",
607607
(PyCFunction)FigureCanvas_flush_events,

0 commit comments

Comments
 (0)