Fix a crash on exit on macOS

Calling Python API functions is not allowed in atexit handlers.

Fixes #3686
This commit is contained in:
Kovid Goyal 2021-06-03 11:54:55 +05:30
parent 2e7b68bf74
commit 93e9d3cb5f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 14 additions and 4 deletions

View File

@ -76,6 +76,8 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- Fix a regression that caused using the ``title`` command in session files
to stop working (:iss:`3676`)
- macOS: Fix a rare crash on exit (:iss:`3686`)
0.20.3 [2021-05-06]
----------------------

View File

@ -160,9 +160,11 @@ static PyObject *notification_activated_callback = NULL;
static PyObject*
set_notification_activated_callback(PyObject *self UNUSED, PyObject *callback) {
if (notification_activated_callback) Py_DECREF(notification_activated_callback);
notification_activated_callback = callback;
Py_INCREF(callback);
Py_CLEAR(notification_activated_callback);
if (callback != Py_None)
notification_activated_callback = callback;
Py_INCREF(callback);
}
Py_RETURN_NONE;
}
@ -638,7 +640,6 @@ cleanup() {
if (dockMenu) [dockMenu release];
dockMenu = nil;
Py_CLEAR(notification_activated_callback);
#ifndef KITTY_USE_DEPRECATED_MACOS_NOTIFICATION_API
drain_pending_notifications(NO);

View File

@ -1182,3 +1182,7 @@ def click_mouse_url(os_window_id: int, tab_id: int, window_id: int) -> None:
def mouse_selection(os_window_id: int, tab_id: int, window_id: int, code: int, button: int) -> None:
pass
def set_notification_activated_callback(cb: Optional[Callable]) -> None:
pass

View File

@ -178,6 +178,9 @@ class AppRunner:
finally:
set_options(None)
free_font_data() # must free font data before glfw/freetype/fontconfig/opengl etc are finalized
if is_macos:
from kitty.fast_data_types import set_notification_activated_callback
set_notification_activated_callback(None)
run_app = AppRunner()