Ensure all windows in OS Window are destroyed when OS Window is closed

This commit is contained in:
Kovid Goyal
2025-04-16 17:20:12 +05:30
parent da753c3f5a
commit 77d2159d3f
2 changed files with 7 additions and 3 deletions

View File

@@ -1817,13 +1817,15 @@ class Boss:
def on_os_window_closed(self, os_window_id: int, viewport_width: int, viewport_height: int) -> None:
self.cached_values['window-size'] = viewport_width, viewport_height
windows_in_os_window = {w.id: w for w in self.window_id_map.values() if w.os_window_id == os_window_id}
tm = self.os_window_map.pop(os_window_id, None)
if tm is not None:
tm.destroy()
for window_id in tuple(w.id for w in self.window_id_map.values() if w.os_window_id == os_window_id):
tm.destroy() # this will call destroy on all windows
for window_id, w in windows_in_os_window.items():
self.child_monitor.mark_for_close(window_id)
self.window_id_map.pop(window_id, None)
self.window_floats_map.pop(window_id, None)
w.destroy() # in case tm was None
if not self.os_window_map and is_macos:
cocoa_set_menubar_title('')
action = self.os_window_death_actions.pop(os_window_id, None)

View File

@@ -1743,10 +1743,12 @@ class Window:
traceback.print_exc()
def destroy(self) -> None:
if self.destroyed:
return
self.destroyed = True
for cw in self.floats:
cw.destroy()
self.call_watchers(self.watchers.on_close, {})
self.destroyed = True
self.clipboard_request_manager.close()
del self.kitten_result_processors
if hasattr(self, 'screen'):