Skip to content

Commit 0822fd0

Browse files
committed
FIX: Flush events when closing figure on macosx
Running the macosx backend without calling show() would cause Timers to pile up and not fire because the event loop was not running. This leaked objects when closing/opening multiple figures. To fix this, we start the event loop momentarily before destroying the figure.
1 parent 34068a7 commit 0822fd0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/matplotlib/backends/backend_macosx.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ def close(self):
152152
Gcf.destroy(self)
153153
self.canvas.flush_events()
154154

155+
def destroy(self):
156+
# We need to run the event loop briefly to clear any
157+
# pending timers and free those objects
158+
self.canvas.start_event_loop(0.01)
159+
super().destroy()
160+
155161
def show(self):
156162
if not self._shown:
157163
self._show()

0 commit comments

Comments
 (0)