From 1b3be9f3bb517356e3bd7296c274ca2403ab71de Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Tue, 16 Aug 2022 20:29:23 -0500 Subject: [PATCH] IPython console: Restore the previous way of closing all clients --- .../plugins/ipythonconsole/widgets/main_widget.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/spyder/plugins/ipythonconsole/widgets/main_widget.py b/spyder/plugins/ipythonconsole/widgets/main_widget.py index 0894162e757..7b5faf0e7dc 100644 --- a/spyder/plugins/ipythonconsole/widgets/main_widget.py +++ b/spyder/plugins/ipythonconsole/widgets/main_widget.py @@ -1938,13 +1938,20 @@ def close_all_clients(self): bool If the closing action was succesful. """ - while self.clients: - client = self.clients.pop() - is_last_client = len(self.get_related_clients(client)) == 0 + # IMPORTANT: **Do not** change this way of closing clients, which uses + # a copy of `self.clients`, because it preserves the main window layout + # when Spyder is closed. + # Fixes spyder-ide/spyder#19084 + open_clients = self.clients.copy() + for client in self.clients: + is_last_client = ( + len(self.get_related_clients(client, open_clients)) == 0) client.close_client(is_last_client) + open_clients.remove(client) # Close all closing shellwidgets. ShellWidget.wait_all_shutdown() + # Close cached kernel self.close_cached_kernel() self.filenames = []