Fix on_quit watchers being called repeatedly when they abort an OS quit request

When an on_quit watcher aborted a quit, the application quit request was
left as CONFIRMABLE_CLOSE_REQUESTED, so process_pending_closes() called
boss.quit() on every tick.
This commit is contained in:
Kovid Goyal 2026-10-16 11:26:07 +05:30
parent 10b3792dfb
commit 92e2fc477c
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 0 deletions

View file

@ -231,6 +231,9 @@ Detailed list of changes
0.50.0 [future]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Fix kitty repeatedly calling ``on_quit`` watchers when a watcher aborts a quit
requested by the OS, for example, via the macOS menu or Dock
- Graphics protocol: Add two new :ref:`indexed color image formats
<indexed_color_data>` whose pixels are indices into the terminal color
palette, so that images automatically change color along with the terminal

View file

@ -2484,6 +2484,7 @@ class Boss:
needs_confirmation = x != 0 and num >= abs(x)
if not needs_confirmation:
if not self._call_on_quit_watchers({'confirmed': True}):
set_application_quit_request(NO_CLOSE_REQUESTED)
return
set_application_quit_request(IMPERATIVE_CLOSE_REQUESTED)
return
@ -2500,6 +2501,7 @@ class Boss:
return
return
if not self._call_on_quit_watchers({'confirmed': False}):
set_application_quit_request(NO_CLOSE_REQUESTED)
return
msg = msg or _('It has {} windows.').format(num)
w = self.confirm(_('Are you sure you want to quit kitty?') + ' ' + msg, self.handle_quit_confirmation, window=active_window, title=_('Quit kitty?'))