degesch: factor out buffer_remove_safe()
This commit is contained in:
parent
1285ba2d13
commit
6f966d4aee
17
degesch.c
17
degesch.c
@ -3129,6 +3129,16 @@ buffer_get_index (struct app_context *ctx, struct buffer *buffer)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
buffer_remove_safe (struct app_context *ctx, struct buffer *buffer)
|
||||
{
|
||||
if (buffer == ctx->current_buffer)
|
||||
buffer_activate (ctx, ctx->last_buffer
|
||||
? ctx->last_buffer
|
||||
: buffer_next (ctx, 1));
|
||||
buffer_remove (ctx, buffer);
|
||||
}
|
||||
|
||||
static void
|
||||
init_global_buffer (struct app_context *ctx)
|
||||
{
|
||||
@ -6718,12 +6728,7 @@ handle_buffer_close (struct app_context *ctx, struct handler_args *a)
|
||||
// The user would be unable to recreate the buffer otherwise
|
||||
if (buffer->type == BUFFER_CHANNEL)
|
||||
part_channel (buffer->server, buffer->channel->name, "");
|
||||
|
||||
if (buffer == ctx->current_buffer)
|
||||
buffer_activate (ctx, ctx->last_buffer
|
||||
? ctx->last_buffer
|
||||
: buffer_next (ctx, 1));
|
||||
buffer_remove (ctx, buffer);
|
||||
buffer_remove_safe (ctx, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user