diff --git a/kitty/state.c b/kitty/state.c index bd7e59ec8..6c138407c 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -230,6 +230,7 @@ set_window_logo(Window *w, const char *path, const ImageAnchorPosition pos, floa if (path && path[0]) { window_logo_id_t wl = find_or_create_window_logo(global_state.all_window_logos, path); if (wl) { + if (w->window_logo.id) decref_window_logo(global_state.all_window_logos, w->window_logo.id); w->window_logo.id = wl; w->window_logo.position = pos; w->window_logo.alpha = alpha; diff --git a/kitty/window_logo.c b/kitty/window_logo.c index 1429327bb..825f7e90b 100644 --- a/kitty/window_logo.c +++ b/kitty/window_logo.c @@ -53,7 +53,10 @@ find_or_create_window_logo(WindowLogoTable *head, const char *path) { WindowLogoItem *s = NULL; unsigned _uthash_hfstr_keylen = (unsigned)uthash_strlen(path); HASH_FIND(hh_path, head->by_path, path, _uthash_hfstr_keylen, s); - if (s) return s->id; + if (s) { + s->refcnt++; + return s->id; + } s = calloc(1, sizeof *s); size_t size; if (!s) { PyErr_NoMemory(); return 0; }