From 23aef2f9ec6ed6365162eaa1d0805dcb2fec24be Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Wed, 30 Aug 2023 21:30:36 +0200 Subject: [PATCH] Use standard method for closing QApp when last window is closed. setQuitOnLastWindowClosed(True) should be equivalent to lastWindowClosed.connect(quit), but is more introspectable (e.g. third-parties can check the value of quitOnLastWindowClosed()). AFAICT the code used lastWindowClosed.connect(quit) because it dates back to Qt3, where setQuitOnLastWindowClosed did not exist yet. --- lib/matplotlib/backends/backend_qt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/backends/backend_qt.py b/lib/matplotlib/backends/backend_qt.py index 62d7a9358544..4b3783bc87ca 100644 --- a/lib/matplotlib/backends/backend_qt.py +++ b/lib/matplotlib/backends/backend_qt.py @@ -140,7 +140,7 @@ def _create_qApp(): image = str(cbook._get_data_path('images/matplotlib.svg')) icon = QtGui.QIcon(image) app.setWindowIcon(icon) - app.lastWindowClosed.connect(app.quit) + app.setQuitOnLastWindowClosed(True) cbook._setup_new_guiapp() if qt_version == 5: app.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps)