Fix visual select window sometimes showing stale window titles

This commit is contained in:
Kovid Goyal
2021-12-31 21:08:20 +05:30
parent 846c774ac2
commit 79ec8b60b9
2 changed files with 3 additions and 1 deletions

View File

@@ -562,8 +562,8 @@ render_window_title(OSWindow *os_window, Screen *screen UNUSED, GLfloat xstart,
unsigned bar_width = (unsigned)ceilf(right - left); 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) { 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); 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.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; if (!window->title_bar_data.buf) return 0;
window->title_bar_data.height = bar_height; window->title_bar_data.height = bar_height;
window->title_bar_data.width = bar_width; 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; 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 #undef RGBCOL
window->title_bar_data.last_drawn_title_object_id = window->title; 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}; static ImageRenderData data = {.group_count=1};
xstart = clamp_position_to_nearest_pixel(xstart, os_window->viewport_width); xstart = clamp_position_to_nearest_pixel(xstart, os_window->viewport_width);

View File

@@ -311,6 +311,7 @@ update_os_window_title(OSWindow *os_window) {
static void static void
destroy_window(Window *w) { destroy_window(Window *w) {
Py_CLEAR(w->render_data.screen); Py_CLEAR(w->title); 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; free(w->title_bar_data.buf); w->title_bar_data.buf = NULL;
release_gpu_resources_for_window(w); release_gpu_resources_for_window(w);
if (w->window_logo.id) { if (w->window_logo.id) {