8000 allow Gcf to destroy unknown managers · matplotlib/matplotlib@7c48cbd · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7c48cbd

Browse files
allow Gcf to destroy unknown managers
1 parent 6840887 commit 7c48cbd

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/matplotlib/_pylab_helpers.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,17 @@ def destroy(cls, num):
5353
It is recommended to pass a manager instance, to avoid confusion when
5454
two managers share the same number.
5555
"""
56-
if all(hasattr(num, attr) for attr in ["num", "_cidgcf", "destroy"]):
56+
if all(hasattr(num, attr) for attr in ["num", "destroy"]):
5757
manager = num
5858
if cls.figs.get(manager.num) is manager:
5959
cls.figs.pop(manager.num)
60-
else:
61-
return
6260
else:
6361
try:
6462
manager = cls.figs.pop(num)
6563
except KeyError:
6664
return
67-
manager.canvas.mpl_disconnect(manager._cidgcf)
65+
if hasattr(manager, "_cidgcf"):
66+
manager.canvas.mpl_disconnect(manager._cidgcf)
6867
manager.destroy()
6968
gc.collect(1)
7069

0 commit comments

Comments
 (0)
0