Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/matplotlib/backends/_backend_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def _blit(argsid):
the ``_blit_args`` dict, since arguments cannot be passed directly.
"""
photoimage, dataptr, offsets, bboxptr, comp_rule = _blit_args.pop(argsid)
if not photoimage.tk.call("info", "commands", photoimage):
return
_tkagg.blit(photoimage.tk.interpaddr(), str(photoimage), dataptr,
comp_rule, offsets, bboxptr)

Expand Down
6 changes: 5 additions & 1 deletion lib/matplotlib/tests/test_backend_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_blit():
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.backends.backend_tkagg # noqa
from matplotlib.backends import _tkagg
from matplotlib.backends import _backend_tk, _tkagg

fig, ax = plt.subplots()
photoimage = fig.canvas._tkphoto
Expand All @@ -93,6 +93,10 @@ def test_blit():
except ValueError:
Comment thread
ksunden marked this conversation as resolved.
print("success")

# Test blitting to a destroyed canvas.
plt.close(fig)
_backend_tk.blit(photoimage, data, (0, 1, 2, 3))


@_isolated_tk_test(success_count=1)
def test_figuremanager_preserves_host_mainloop():
Expand Down