xC: deal with conflicts when renaming buffers

This commit is contained in:
Přemysl Eric Janouch 2022-08-29 15:04:37 +02:00
parent ef8f25d1dd
commit b454920c81
Signed by: p
GPG Key ID: A0420B94F92B9493
2 changed files with 5 additions and 7 deletions

2
NEWS
View File

@ -12,6 +12,8 @@ Unreleased
* xC: made it show WALLOPS messages, as PRIVMSG for the server buffer * xC: made it show WALLOPS messages, as PRIVMSG for the server buffer
* xC: various bugfixes
* xD: implemented WALLOPS, choosing to make it target even non-operators * xD: implemented WALLOPS, choosing to make it target even non-operators

10
xC.c
View File

@ -7155,7 +7155,7 @@ irc_handle_nick (struct server *s, const struct irc_message *msg)
str_map_set (&s->irc_buffer_map, user->nickname, NULL); str_map_set (&s->irc_buffer_map, user->nickname, NULL);
str_map_set (&s->irc_buffer_map, new_nickname, pm_buffer); str_map_set (&s->irc_buffer_map, new_nickname, pm_buffer);
char *x = xstrdup_printf ("%s.%s", s->name, new_nickname); char *x = irc_make_buffer_name (s, new_nickname);
buffer_rename (s->ctx, pm_buffer, x); buffer_rename (s->ctx, pm_buffer, x);
free (x); free (x);
} }
@ -8768,18 +8768,14 @@ server_rename (struct app_context *ctx, struct server *s, const char *new_name)
struct buffer *buffer; struct buffer *buffer;
while ((buffer = str_map_iter_next (&iter))) while ((buffer = str_map_iter_next (&iter)))
{ {
// TODO: creation of buffer names should be centralized -> replace
// calls to buffer_rename() and manual setting of buffer names
// with something like buffer_autorename() -- just mind the mess
// in irc_handle_nick(), which can hopefully be simplified
char *x = NULL; char *x = NULL;
switch (buffer->type) switch (buffer->type)
{ {
case BUFFER_PM: case BUFFER_PM:
x = xstrdup_printf ("%s.%s", s->name, buffer->user->nickname); x = irc_make_buffer_name (s, buffer->user->nickname);
break; break;
case BUFFER_CHANNEL: case BUFFER_CHANNEL:
x = xstrdup_printf ("%s.%s", s->name, buffer->channel->name); x = irc_make_buffer_name (s, buffer->channel->name);
break; break;
default: default:
hard_assert (!"unexpected type of server-related buffer"); hard_assert (!"unexpected type of server-related buffer");