Skip to content

Commit 7839dd8

Browse files
Clear nonlocal socket notifier variable on cleanup
Although in normal operation this shouldn't matter (it will go out of scope anyway), it would be better if any future bugs here raised a `TypeError` upon encountering `sn` being `None` instead of experiencing an ungraceful shutdown due to SIGABRT upon attempting to access a no-longer-existing C++ object.
1 parent 37e7cce commit 7839dd8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/matplotlib/backends/backend_qt.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,10 @@ def _may_clear_sock():
175175

176176
def handle_sigint():
177177
# Ensure notifier does not outlive the event loop shutting down:
178+
nonlocal sn
178179
sn.deleteLater()
179180
QtCore.QCoreApplication.sendPostedEvents(sn, QtCore.QEvent.Type.DeferredDelete)
181+
sn = None
180182
if hasattr(qapp_or_eventloop, 'closeAllWindows'):
181183
qapp_or_eventloop.closeAllWindows()
182184
qapp_or_eventloop.quit()

0 commit comments

Comments
 (0)