diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2015-07-14 06:11:14 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2015-07-14 06:11:14 +0200 |
commit | 6f966d4aeebd07d5118a62102a2bc5b878903a9e (patch) | |
tree | c016b22ade9c69ef987c8d6bdded952634f605cd | |
parent | 1285ba2d13230851c3de0a48482e735a2116de1c (diff) | |
download | xK-6f966d4aeebd07d5118a62102a2bc5b878903a9e.tar.gz xK-6f966d4aeebd07d5118a62102a2bc5b878903a9e.tar.xz xK-6f966d4aeebd07d5118a62102a2bc5b878903a9e.zip |
degesch: factor out buffer_remove_safe()
-rw-r--r-- | degesch.c | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -3130,6 +3130,16 @@ buffer_get_index (struct app_context *ctx, struct buffer *buffer) } 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) { struct buffer *global = ctx->global_buffer = buffer_new (); @@ -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); } } |