From 28dc76fcf6e499c01bf33ad47fd8ddef9e8d9da7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 7 Jul 2026 19:53:32 +0530 Subject: [PATCH] Free global VAO on terminate --- kitty/glfw.c | 1 + kitty/shaders.c | 8 ++++++++ kitty/state.h | 1 + 3 files changed, 10 insertions(+) diff --git a/kitty/glfw.c b/kitty/glfw.c index adf2f186e..db06327a3 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -2133,6 +2133,7 @@ glfw_init(PyObject UNUSED *self, PyObject *args) { static PyObject* glfw_terminate(PYNOARG) { + cleanup_shader_resources_on_terminate(); for (size_t i = 0; i < arraysz(cursors); i++) { if (cursors[i].is_custom && cursors[i].glfw) { glfwDestroyCursor(cursors[i].glfw); diff --git a/kitty/shaders.c b/kitty/shaders.c index 41d003520..30b349e79 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -1867,6 +1867,14 @@ free_vao(ssize_t vao_idx) { remove_vao(vao_idx); } +void +cleanup_shader_resources_on_terminate(void) { + if (shader_globals_vao_idx != -1) { + remove_vao(shader_globals_vao_idx); + shader_globals_vao_idx = -1; + } +} + static void finalize(void) { default_visual_bell_animation = free_animation(default_visual_bell_animation); diff --git a/kitty/state.h b/kitty/state.h index f9f373a40..553054156 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -555,6 +555,7 @@ sprite_index_to_pos(unsigned idx, unsigned xnum, unsigned ynum, unsigned *x, uns void initialize_gpu(void); void free_vao(ssize_t vao_idx); +void cleanup_shader_resources_on_terminate(void); bool remove_os_window(id_type os_window_id); void* make_os_window_context_current(OSWindow *w); void set_os_window_size(OSWindow *os_window, int x, int y);