Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 098532b

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 098532b

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,11 +175,13 @@ 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)
180181
if hasattr(qapp_or_eventloop, 'closeAllWindows'):
181182
qapp_or_eventloop.closeAllWindows()
182183
qapp_or_eventloop.quit()
184+
sn = None
183185

184186
return _allow_interrupt(prepare_notifier, handle_sigint)
185187

0 commit comments

Comments
 (0)