From 92e2fc477ceb04aa32b97b8f9716b892c346b9ff Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 16 Oct 2026 11:26:07 +0530 Subject: [PATCH] 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. --- docs/changelog.rst | 3 +++ kitty/boss.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 13573ecb6..fb129db12 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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 ` whose pixels are indices into the terminal color palette, so that images automatically change color along with the terminal diff --git a/kitty/boss.py b/kitty/boss.py index c75296dc5..fca8e4168 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -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?'))