From 6021ee85cb3c13754a0f205469824e7f9fb0df69 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sun, 23 Apr 2006 08:19:06 +0000 Subject: Fixed bug #16416 (crash when purging old DCC chats) --- src/gui/gui-buffer.c | 4 ++++ src/irc/irc-dcc.c | 19 +++++++++++++++++++ src/irc/irc.h | 1 + weechat/src/gui/gui-buffer.c | 4 ++++ weechat/src/irc/irc-dcc.c | 19 +++++++++++++++++++ weechat/src/irc/irc.h | 1 + 6 files changed, 48 insertions(+) diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index 3f7107bc3..c57207384 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -435,6 +435,10 @@ gui_buffer_free (t_gui_buffer *buffer, int switch_to_another) if (buffer->type == BUFFER_TYPE_RAW_DATA) gui_buffer_raw_data = NULL; + + /* purge DCC chat using this buffer */ + if (CHANNEL(buffer)) + dcc_chat_remove_channel (CHANNEL(buffer)); for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server) diff --git a/src/irc/irc-dcc.c b/src/irc/irc-dcc.c index 11d28cf8b..378625b8e 100644 --- a/src/irc/irc-dcc.c +++ b/src/irc/irc-dcc.c @@ -509,6 +509,25 @@ dcc_channel_for_chat (t_irc_dcc *ptr_dcc) GUI_COLOR(COLOR_WIN_CHAT)); } +/* + * dcc_chat_remove_channel: remove a buffer for DCC chat + */ + +void +dcc_chat_remove_channel (t_irc_channel *channel) +{ + t_irc_dcc *ptr_dcc; + + if (!channel) + return; + + for (ptr_dcc = dcc_list; ptr_dcc; ptr_dcc = ptr_dcc->next_dcc) + { + if (ptr_dcc->channel == channel) + ptr_dcc->channel = NULL; + } +} + /* * dcc_recv_connect_init: connect to sender and init file or chat */ diff --git a/src/irc/irc.h b/src/irc/irc.h index 898188608..dfab3e766 100644 --- a/src/irc/irc.h +++ b/src/irc/irc.h @@ -406,6 +406,7 @@ extern void nick_print_log (t_irc_nick *); extern void dcc_redraw (int); extern void dcc_free (t_irc_dcc *); extern void dcc_close (t_irc_dcc *, int); +extern void dcc_chat_remove_channel (t_irc_channel *); extern void dcc_accept (t_irc_dcc *); extern void dcc_accept_resume (t_irc_server *, char *, int, unsigned long); extern void dcc_start_resume (t_irc_server *, char *, int, unsigned long); diff --git a/weechat/src/gui/gui-buffer.c b/weechat/src/gui/gui-buffer.c index 3f7107bc3..c57207384 100644 --- a/weechat/src/gui/gui-buffer.c +++ b/weechat/src/gui/gui-buffer.c @@ -435,6 +435,10 @@ gui_buffer_free (t_gui_buffer *buffer, int switch_to_another) if (buffer->type == BUFFER_TYPE_RAW_DATA) gui_buffer_raw_data = NULL; + + /* purge DCC chat using this buffer */ + if (CHANNEL(buffer)) + dcc_chat_remove_channel (CHANNEL(buffer)); for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server) diff --git a/weechat/src/irc/irc-dcc.c b/weechat/src/irc/irc-dcc.c index 11d28cf8b..378625b8e 100644 --- a/weechat/src/irc/irc-dcc.c +++ b/weechat/src/irc/irc-dcc.c @@ -509,6 +509,25 @@ dcc_channel_for_chat (t_irc_dcc *ptr_dcc) GUI_COLOR(COLOR_WIN_CHAT)); } +/* + * dcc_chat_remove_channel: remove a buffer for DCC chat + */ + +void +dcc_chat_remove_channel (t_irc_channel *channel) +{ + t_irc_dcc *ptr_dcc; + + if (!channel) + return; + + for (ptr_dcc = dcc_list; ptr_dcc; ptr_dcc = ptr_dcc->next_dcc) + { + if (ptr_dcc->channel == channel) + ptr_dcc->channel = NULL; + } +} + /* * dcc_recv_connect_init: connect to sender and init file or chat */ diff --git a/weechat/src/irc/irc.h b/weechat/src/irc/irc.h index 898188608..dfab3e766 100644 --- a/weechat/src/irc/irc.h +++ b/weechat/src/irc/irc.h @@ -406,6 +406,7 @@ extern void nick_print_log (t_irc_nick *); extern void dcc_redraw (int); extern void dcc_free (t_irc_dcc *); extern void dcc_close (t_irc_dcc *, int); +extern void dcc_chat_remove_channel (t_irc_channel *); extern void dcc_accept (t_irc_dcc *); extern void dcc_accept_resume (t_irc_server *, char *, int, unsigned long); extern void dcc_start_resume (t_irc_server *, char *, int, unsigned long); -- cgit v1.2.3