Revert previous. Causes a crash as reported by Tom Murphy.

This commit is contained in:
tim 2020-03-14 16:11:09 +00:00
parent 146fa08e4d
commit b9213d0a02

View File

@ -668,23 +668,21 @@ void
client_set_name(struct client_ctx *cc) client_set_name(struct client_ctx *cc)
{ {
struct winname *wn; struct winname *wn;
char *newname;
int i = 0; int i = 0;
free(cc->name); if (!xu_get_strprop(cc->win, ewmh[_NET_WM_NAME], &newname))
if (!xu_get_strprop(cc->win, ewmh[_NET_WM_NAME], &cc->name)) if (!xu_get_strprop(cc->win, XA_WM_NAME, &newname))
if (!xu_get_strprop(cc->win, XA_WM_NAME, &cc->name)) newname = xstrdup("");
cc->name = xstrdup("");
TAILQ_FOREACH(wn, &cc->nameq, entry) { TAILQ_FOREACH(wn, &cc->nameq, entry) {
if (strcmp(wn->name, cc->name) == 0) { if (strcmp(wn->name, newname) == 0)
TAILQ_REMOVE(&cc->nameq, wn, entry); TAILQ_REMOVE(&cc->nameq, wn, entry);
free(wn->name);
free(wn);
}
i++; i++;
} }
cc->name = newname;
wn = xmalloc(sizeof(*wn)); wn = xmalloc(sizeof(*wn));
wn->name = xstrdup(cc->name); wn->name = xstrdup(newname);
TAILQ_INSERT_TAIL(&cc->nameq, wn, entry); TAILQ_INSERT_TAIL(&cc->nameq, wn, entry);
/* Garbage collection. */ /* Garbage collection. */