diff --git a/kitty/shaders.c b/kitty/shaders.c index 81d7bcf24..f448c8f0d 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -562,8 +562,8 @@ render_window_title(OSWindow *os_window, Screen *screen UNUSED, GLfloat xstart, unsigned bar_width = (unsigned)ceilf(right - left); if (!window->title_bar_data.buf || window->title_bar_data.width != bar_width || window->title_bar_data.height != bar_height) { free(window->title_bar_data.buf); + Py_CLEAR(window->title_bar_data.last_drawn_title_object_id); window->title_bar_data.buf = malloc((size_t)4 * bar_width * bar_height); - window->title_bar_data.last_drawn_title_object_id = NULL; if (!window->title_bar_data.buf) return 0; window->title_bar_data.height = bar_height; window->title_bar_data.width = bar_width; @@ -575,6 +575,7 @@ render_window_title(OSWindow *os_window, Screen *screen UNUSED, GLfloat xstart, if (!draw_window_title(os_window, title, RGBCOL(highlight_fg, default_fg), RGBCOL(highlight_bg, default_bg), window->title_bar_data.buf, bar_width, bar_height)) return 0; #undef RGBCOL window->title_bar_data.last_drawn_title_object_id = window->title; + Py_INCREF(window->title_bar_data.last_drawn_title_object_id); } static ImageRenderData data = {.group_count=1}; xstart = clamp_position_to_nearest_pixel(xstart, os_window->viewport_width); diff --git a/kitty/state.c b/kitty/state.c index c5fea20e0..1de2752eb 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -311,6 +311,7 @@ update_os_window_title(OSWindow *os_window) { static void destroy_window(Window *w) { Py_CLEAR(w->render_data.screen); Py_CLEAR(w->title); + Py_CLEAR(w->title_bar_data.last_drawn_title_object_id); free(w->title_bar_data.buf); w->title_bar_data.buf = NULL; release_gpu_resources_for_window(w); if (w->window_logo.id) {